Compare commits

..

389 Commits

Author SHA1 Message Date
nou 3f88e5fe83 Reopen console on windows when started from cmd.exe 2026-03-26 14:46:23 +01:00
nou 6a537642ab Add copy files to database view 2026-03-22 21:10:04 +01:00
nou b7f1a0abc9 Add id_file_key index to database 2026-03-22 09:55:19 +01:00
nou 33c976d3c9 Remember a selected filter keyword in database view 2026-03-22 09:54:57 +01:00
nou a17001cdf9 Trim whitespace string from XISF 2026-03-21 22:21:35 +01:00
nou 305c1d1f55 Deffered SQL query when database is visible 2026-03-21 20:33:47 +01:00
nou 95808b094d Fix buidling query 2026-03-21 20:31:44 +01:00
nou 2b56af27fe Add explicit link to Svg module to solve some issues with SVG icon 2026-03-15 17:47:51 +01:00
nou 8edf746827 Use bindvalue in DatabaseTableView 2026-03-15 17:47:24 +01:00
nou 729a330e6c Add backspace as move to trash shortcut for MacOS 2026-03-15 17:45:01 +01:00
nou 1ac5a4e42a Update metainfo 2026-02-16 22:52:28 +01:00
nou 83d212aa91 Enable sorting of FITS header 2026-02-16 22:29:25 +01:00
nou bd24fba407 Update README 2026-02-11 21:26:33 +01:00
nou 3448f62f31 Try to fix crash in ImageRingList 2026-01-19 20:57:13 +01:00
nou 567e66acb5 Update libXISF 2025-11-02 23:17:10 +01:00
nou 9e79133464 Fix compile error 2025-11-01 12:11:53 +01:00
nou e08107aa13 Improve Save as 2025-11-01 12:06:24 +01:00
nou 6eda2c4e48 Remove some code 2025-10-20 23:48:47 +02:00
nou b16ae3a9ee Add language setting 2025-10-20 21:29:59 +02:00
nou 56bba27ae3 Give save filter only formats that are supported 2025-10-20 00:23:11 +02:00
nou 1070dc32c1 Update metainfo 2025-09-15 15:55:00 +02:00
nou f61cf12f0a Update help files 2025-09-15 15:49:30 +02:00
nou 530b0c62c3 Open parent directory if it doesn't exist 2025-09-15 15:49:16 +02:00
nou 7e95440dd6 Update translations 2025-09-15 10:58:29 +02:00
nou 03492972cb Include all types in completion 2025-09-14 20:44:36 +02:00
nou 9cca183677 Working copy/move operation 2025-09-14 20:44:07 +02:00
nou afd059b36b Add some margins when retriving objects 2025-09-14 13:43:20 +02:00
nou 1b9f218acb Console line with simple auto completion 2025-08-17 17:39:01 +02:00
nou 32f91d7b2f Add PCL:AstrometricSolution to XISF solved files 2025-08-03 20:58:01 +02:00
nou 69fbad34b6 Add image index to FITSRecordModify 2025-08-03 20:57:33 +02:00
nou e026042604 Use ifFITS isXISF functions 2025-08-03 20:37:40 +02:00
nou bb7e5182af Fix metainfo linter 2025-07-27 17:45:23 +02:00
nou f0152e2496 Fix compilation issue 2025-07-27 17:33:14 +02:00
nou eccf928032 Make path in file manager editable 2025-07-27 16:29:44 +02:00
nou 897306d1c3 Add fitskeyword.ui 2025-07-27 15:40:06 +02:00
nou cbc779090f Prioritize M number then IC for object name 2025-07-27 15:36:19 +02:00
nou d826744f26 Add tabs to file manager 2025-07-27 15:35:25 +02:00
nou 3bdfb12d4f Disable use of QFileSystemModel on ARM platform 2025-07-27 10:06:38 +02:00
nou c416ae9941 Fix suffix handling, do not index PCL: properties 2025-07-26 18:19:46 +02:00
nou abbba2890f Add context menu to hide columns in file manager 2025-07-26 17:50:54 +02:00
nou 9c6847d334 Do not pass XISF properies into WCS 2025-07-26 15:49:21 +02:00
nou af1c26a9fe Use PCL:AstrometricSolution properties to construct WCS 2025-07-26 15:48:58 +02:00
nou e0441a6494 Change type to uint64_t 2025-07-24 20:22:06 +02:00
nou a88f05a9fe Add filemanager 2025-07-21 20:16:34 +02:00
nou b58559a18a Update modify FITS header script 2025-07-13 10:43:15 +02:00
nou 2ac14a6c04 Fix thumbnailer compilation 2025-07-13 10:42:59 +02:00
nou b84256625c Add stellarsolver6 as name 2025-06-12 16:48:09 +02:00
nou 202a2b11b7 Add marked files in batch processing 2025-06-09 19:09:50 +02:00
nou 32f192ed7e Add draw grid button 2025-05-31 00:19:15 +02:00
nou a0422683bd Move source files to src directory 2025-05-30 16:49:33 +02:00
nou ce67b35bfa Mention OpenNGC 2025-05-29 23:44:55 +02:00
nou f016500f12 Include ngc db 2025-05-29 17:39:13 +02:00
nou 6069ebbbac Refractor drawing grid 2025-05-27 16:26:03 +02:00
nou e587d84e05 Remove that empty action 2025-05-26 17:05:19 +02:00
nou c01f2e328a Add sky grid painting 2025-05-26 15:50:37 +02:00
nou 8b498bbe73 Prefer writing keyword as integer 2025-05-24 23:13:14 +02:00
nou c6bc792ff7 Update metainfo 2025-04-29 16:03:30 +02:00
nou 1a307d82f9 Update translations 2025-04-29 15:59:59 +02:00
nou 8c5e2b2ebf Update help 2025-04-29 14:07:16 +02:00
nou 03ad135ef0 Fix bestFit line color 2025-04-29 13:31:42 +02:00
nou 2a78a9a41d Add XISF mime type 2025-04-29 13:15:45 +02:00
nou 1a214a169e Blind and update question for platesolve script 2025-04-28 17:25:07 +02:00
nou f8704c51d8 FITS hightlight settings 2025-04-28 17:06:24 +02:00
nou 3feee0256c New core.question script method 2025-04-28 17:04:45 +02:00
nou 53472d807c Adding new scripts 2025-04-27 22:54:29 +02:00
nou 9f06269aa4 Improve chart graph 2025-04-27 17:43:32 +02:00
nou 78f242d808 Extending script plot() function 2025-04-23 13:37:47 +02:00
nou e6bab45a89 Fix index of subimage for XISF 2025-04-15 20:58:03 +02:00
nou 58286d52c5 TextFile scripting 2025-04-15 11:09:23 +02:00
nou bac1963fa4 Add stretch toolbar actions to view menu 2025-04-11 17:05:31 +02:00
nou 2415717ce0 Add STFSlider ability to be vertical 2025-04-10 23:09:59 +02:00
nou e7acbca01e Color highlight FITS header 2025-04-10 19:58:29 +02:00
nou 7c4118b0b6 Fix bug in script solver 2025-04-10 00:34:14 +02:00
nou 8178efdafd Reload image when header is updated 2025-04-09 14:58:23 +02:00
nou 90026f931f Add open file and open file location to DB view 2025-04-02 20:27:59 +02:00
nou eee4613b25 Add plot() script method 2025-04-02 20:27:19 +02:00
nou 24a9e96bbf Streamline standalone thumbnailer 2025-04-02 15:24:41 +02:00
nou 5af5f4f068 Navigation menu 2025-04-02 12:24:17 +02:00
nou 85f9822b96 Fix prevSubImage 2025-03-25 18:26:08 +01:00
nou 7fc6c64fd7 Make help windows non modal 2025-03-24 22:09:18 +01:00
nou 4488c2e6af Always make 4 channels 2025-03-24 22:08:54 +01:00
nou 0047607c1d Add loading sub images 2025-03-23 13:33:34 +01:00
nou 45c368bbbb Remove usage of SLOT() and SIGNAL() 2025-03-19 13:50:39 +01:00
nou c96cb86a29 Show relative path in title bar for when browsing dir recursive 2025-03-19 13:14:04 +01:00
nou fe3e5f66be Release 20250318 2025-03-18 17:29:19 +01:00
nou 6fd17fbdf5 Use only single database 2025-03-18 14:46:08 +01:00
nou f30dd2a520 Add generating thumbnails from cmd line 2025-03-17 11:08:18 +01:00
nou 21675d9479 Add install thumbnailer button 2025-03-17 11:07:42 +01:00
nou f669baa8a6 Drop lib prefix for dll 2025-03-10 11:26:43 +01:00
nou c317012c99 Configurable threshold 2025-03-10 03:05:44 -07:00
nou d0dbef20c7 Fix handling of inf and nan in TFloat16 2025-03-10 11:03:17 +01:00
nou bd45900821 Finish standalone thumbnailer under 2025-03-10 11:01:45 +01:00
nou 96a89bff92 fixup! Fix images that have values outside of 0-1 range 2025-03-09 17:51:26 +01:00
nou c05fc36ee3 Add FITS to thumbnailer 2025-03-06 18:36:48 +01:00
nou 05b0aa9a2f Add custom implementation of half float 2025-03-06 15:35:12 +01:00
nou 7b70b6cce5 Use texture2DArray for colormap to work with OpenGL ES 2025-03-05 21:14:43 +01:00
nou 5150ec5639 Fix images that have values outside of 0-1 range 2025-03-04 16:09:33 +01:00
nou 79529552d9 Thumbnailer for windows 2025-03-04 06:53:47 -08:00
nou c872c72bb5 Release 20250302 2025-03-02 17:31:24 +01:00
nou 58abf762c0 Fix Do not prepend \\ to network share paths 2025-03-02 17:09:33 +01:00
nou e47c99fd21 Update translations 2025-03-02 14:41:31 +01:00
nou 24ddf1dc61 Add ability to have user defined colormaps 2025-03-02 14:32:09 +01:00
nou 8f333191c3 Update help 2025-03-02 14:31:29 +01:00
nou e4cb99657e Move aspect to resize in parameters 2025-03-02 13:45:58 +01:00
nou d644e8095d Small fix for help dialog 2025-03-02 13:45:39 +01:00
nou 1796e128ad For setSolverProfile use index 1-8 2025-03-02 13:45:31 +01:00
nou 37fdac39dc Add best fit on image load 2025-03-02 13:44:59 +01:00
nou 13e1abf07e Add autotrech to conversion 2025-03-01 14:24:28 +01:00
nou 617abf7afe Better handling of FITS loading error 2025-02-28 10:42:39 +01:00
nou d59ee7fddc Add additional colormaps 2025-02-28 10:41:12 +01:00
nou d545c6ca0f Do not prepend \\ to network share paths 2025-02-26 20:43:46 +01:00
nou 5249b277ec Add integer resample 2025-02-25 17:41:29 +01:00
nou e4b9fefa5a Move MTFParam 2025-02-25 17:35:55 +01:00
nou d069ce3302 Add shortcut to 100% zoom 2025-02-23 09:45:29 +01:00
nou 58c182adc0 Add thumbnailer 2025-02-16 23:36:25 +01:00
nou c36068aaf4 Fix mxe build 2025-02-16 16:19:39 +01:00
nou fcb3aec81f Remove startfit 2025-02-16 15:22:38 +01:00
nou 7510dac82b Reorginize code 2025-02-16 15:19:20 +01:00
nou 55439be04c Add Portuguese translation thanks to John Peter Sá 2025-02-07 15:10:19 +01:00
nou 0ff2001797 Handle MAX_PATH every where 2025-01-26 16:00:00 +01:00
nou fc36024eee Remove deprecated QSqlQuery usage 2025-01-19 15:49:31 +01:00
nou 3cda53f26c Do not attempt open not existing file 2025-01-19 15:11:32 +01:00
nou 58d18cc28a Remove unused function 2025-01-19 15:11:14 +01:00
nou 2b96da60de Do not use global thread pool 2025-01-12 10:59:12 +01:00
nou 236f66ed2f Add solver profile to script engine 2024-12-27 23:20:51 +01:00
nou a86c100e69 Fix issue with Qt 6.8 2024-12-22 12:19:34 +01:00
nou 45ee9b7258 Fix half pixel offset and add filtering in sw rendering
Signed-off-by: Dušan Poizl <nou.spiro@gmail.com>
2024-12-05 16:02:46 +01:00
nou be1e65251d Support really big images 50000px 2024-11-30 22:03:58 +01:00
nou 9b7837e9fb SW rendering when image is too big for texture 2024-11-27 20:21:57 +01:00
nou 4afa940886 Update metainfo 2024-11-16 22:58:34 +01:00
nou d1344d2dc8 Add support for uint32 and double in boxResample 2024-11-15 23:29:22 +01:00
nou 24eea573e6 Handle all data types when converting to QImage 2024-10-29 19:43:16 +01:00
nou 8f7f527732 Add RawImage::convertToType() 2024-10-29 19:42:36 +01:00
nou 3635ac00cb Fix alpha channel in fromPlanarSSE 2024-10-29 19:39:37 +01:00
nou eba9110933 Remove dead code 2024-10-29 15:32:06 +01:00
nou 464207beb1 Apply index folder directory change immediatly 2024-10-24 20:15:06 +02:00
nou 4aeff61c44 Add TIFF as valid format for script convert 2024-10-13 19:58:13 +02:00
nou 790c836bbd MXE build 2024-10-13 19:58:12 +02:00
nou 62616898ed Forgot to add fts and fz to one place 2024-10-13 19:57:21 +02:00
nou e216af6a6d Better handling of missing and overwrite files 2024-10-13 19:57:21 +02:00
nou e0d6f417a0 fixup! Fix compiling without stellarsolver 2024-10-04 20:51:53 +02:00
nou 3c5fef988e Fix compiling without stellarsolver 2024-10-02 15:25:32 +02:00
nou 6c42315f87 Update metainfo 2024-10-02 11:58:39 +02:00
nou 06b3dbc1bb Update help and translation 2024-10-02 11:52:35 +02:00
nou 258553a6bb Change url for downloading 2024-10-02 10:08:50 +02:00
nou 9c40ce2daa Add open marked files 2024-10-02 00:10:07 +02:00
nou 9f4c4c8bdc Refining platesolving 2024-10-01 17:37:34 +02:00
nou da1aa4c6fc Updating FITS header 2024-09-30 21:19:23 +02:00
nou a43f12565d Add FTS and FZ as FITS file suffix 2024-09-30 19:56:53 +02:00
nou 32973c54ce Adding platesolving 2024-09-30 18:39:35 +02:00
nou dccb2e88da Working solver 2024-09-20 14:34:21 +02:00
nou c8898387fe Http download of index files 2024-09-19 15:28:57 +02:00
nou dfe31b6350 In live mode reload immediatly 2024-09-19 13:40:41 +02:00
nou 553e72a5ce Add check for new version 2024-09-19 13:40:41 +02:00
nou 12901c9a47 Fix that comment in FITS record contained value 2024-09-17 23:06:16 +02:00
nou da79197376 Initial stellarsolver implementation 2024-09-17 23:05:27 +02:00
nou 30960033c5 Refractor ImageScrollArea 2024-09-17 12:31:55 +02:00
nou efd3ff35f3 Fix unpack aligment 2024-09-14 23:12:50 +02:00
nou 52bcb10da1 Proper LCMS2 link don't use OpenGL ES on MacOS 2024-08-27 15:27:27 +02:00
nou 9adfbde512 Remember auto stretch on load 2024-08-27 13:43:17 +02:00
nou e38de510a0 Open also file:// 2024-08-27 13:17:53 +02:00
nou 5e18c591f7 Add support for FLOAT16 image downscale 2024-08-27 11:39:47 +02:00
nou d6e257e201 Use flatpak trash portal instad of g_file_trash 2024-08-26 11:43:57 +02:00
nou 2c7a7d473f Fix output path browse dialog path 2024-08-26 10:19:48 +02:00
nou 87d7bd2d9f Add delay to directory reload 2024-08-25 22:20:41 +02:00
nou 79dd7d91eb Fix fromPlanaerSSE 2024-08-25 17:55:59 +02:00
nou 21b4e0934c Set GL_UNPACK_ALIGNMENT 2024-08-25 17:55:47 +02:00
nou 0239aba165 Debayer fix on OpenGL ES 2024-08-25 14:39:07 +02:00
nou 1b08242433 Use OpenGL ES on ARM by default 2024-08-25 12:49:14 +02:00
nou a56e8a2c27 Fix bug with thumbnails on OpenGL ES 2024-08-25 12:41:12 +02:00
nou bf360c1ae1 Fix thumbnails draw 2024-08-24 18:17:41 +02:00
nou 1ec3a6cffd Revert change in app id 2024-08-24 17:49:01 +02:00
nou 100f47746c Fix path 2024-08-24 17:14:10 +02:00
nou 02bac0c850 Fix compiler error with float16 2024-08-24 17:14:02 +02:00
nou bc29dc7d34 Use lcms2 for color profiles 2024-08-24 16:37:06 +02:00
nou ff5053b626 Added missing case FLOAT16 2024-08-22 19:10:26 +02:00
nou 511802bdbd Usable OpenGL ES 2024-08-22 17:54:26 +02:00
nou dd16a02045 Preparation for OpenGL ES 2024-08-20 17:53:30 +02:00
nou 7ed38cf6d7 Additional missing dependencies 2024-08-20 17:51:52 +02:00
nou 8c6b451564 Suggestion by Der_Pit 2024-08-17 19:56:01 +02:00
nou d288810d5d Fix saving image 2024-08-16 15:16:37 +02:00
nou fb66e82428 Workaround for huge PCL keywords 2024-08-16 15:04:25 +02:00
nou 71486efeef Remove unused method 2024-06-17 09:47:56 +02:00
nou 8213f6213f Fix convert scripts 2024-06-17 09:44:48 +02:00
nou f8c9fec77e Add scripts 2024-06-16 16:31:53 +02:00
nou af4be850cb Embeded scripts 2024-06-16 00:14:51 +02:00
nou ca1a13ed9d Solve deprectation warnings 2024-06-15 17:45:30 +02:00
nou 1873da6c49 Fix issue in thumbnails 2024-06-11 17:09:35 +02:00
nou 92345f82ca Update metainfo 2024-06-10 22:39:52 +02:00
nou 3c8f49e932 Fix some bugs in scripting 2024-06-10 18:55:13 +02:00
nou 37dd97e361 Fix compilation error 2024-06-10 16:46:21 +02:00
nou da31187aa3 Fix small typo in help 2024-06-09 17:15:53 +02:00
nou 4801338160 Fix compilation error 2024-06-09 15:47:30 +02:00
nou fb9d026ff5 Open script folder on MacOS 2024-06-09 15:42:31 +02:00
nou c2810faf8f Update french translation 2024-06-09 13:56:04 +02:00
nou d3d302fd38 Fix some typos in help 2024-06-08 23:02:13 +02:00
nou a0497c7d19 Update translations 2024-06-08 21:19:14 +02:00
nou 8818e25eda Help documentation for batch processing 2024-06-08 20:21:46 +02:00
nou c3baa18087 Fix text color in log 2024-06-08 20:19:48 +02:00
nou 66f0c05a48 Fix calling GUI methods from script thread 2024-06-08 20:11:25 +02:00
nou 461ffea874 Default params for convert() 2024-06-08 19:42:21 +02:00
nou 7535ad87e7 Batchprocessing improvments 2024-06-06 12:00:00 +02:00
nou 273aef1594 Add getInt getString getFloat methods to scripting 2024-06-05 22:27:35 +02:00
nou 9519c9830c Improve text coloring in log 2024-06-04 16:41:50 +02:00
nou 342e5cc5db Add FITSRecordModify for XISF files 2024-06-04 16:41:25 +02:00
nou ae84cbdfe0 Add modifing FITS records 2024-04-12 09:58:21 +02:00
nou 933fd4a2a0 Additional work on batch processing 2024-03-29 18:08:57 +01:00
nou c3588e1c36 Rate limit conversion from script 2024-03-26 14:54:19 +01:00
nou 174134a9ee Skip dummy HDU in compressed FITS 2024-03-25 22:53:51 +01:00
nou bbc13ec8a5 Add compression parameters 2024-03-25 22:53:13 +01:00
nou 9f7e2ab6b4 Add convert function to script 2024-03-25 20:25:47 +01:00
nou 4fe56acbd9 Fix bug when saving color FITS/XISF files 2024-03-24 23:55:50 +01:00
nou f35db9d1af Small fixes 2024-03-24 18:39:46 +01:00
nou 81d138f799 Add bayer mask icons 2024-02-12 17:57:35 +01:00
nou ae07d4793b Draw only visible filenames in thumbnails 2024-02-11 13:52:52 +01:00
nou dc2a781d3b Add calculating stats with script 2024-02-04 00:11:31 +01:00
nou 90035f44ed Refractor LoadRunable 2024-02-04 00:09:46 +01:00
nou 53c9a58125 Prevent symlink loop when indexing 2024-02-03 15:32:34 +01:00
nou 3f7e3689e8 Prevent symlink loops 2024-02-02 22:41:44 +01:00
nou af9187737f Add recursive directory 2024-02-02 20:55:58 +01:00
nou 4e952873e3 Fix metainfo 2024-02-02 00:09:42 +01:00
nou fb24800050 Add DBus for MacOS to fix build issue 2024-02-01 23:27:40 +01:00
nou ea0dcc226a Update metainfo 2024-02-01 23:26:08 +01:00
nou 6a7b677b95 Translatiotions 2024-02-01 23:22:35 +01:00
nou 0cee4c9c53 Add thumbnail quality to settings 2024-02-01 23:03:21 +01:00
nou d5f2351905 Only degress should show negative sign 2024-01-22 21:32:15 +01:00
nou 18732a8cbf Limit image info to 1024 characters 2024-01-22 21:31:28 +01:00
nou 8c9c1d8d06 Flip image according to ROWORDER 2024-01-22 21:30:39 +01:00
nou e5f425ff8d Fix some edge cases when stretch 2024-01-18 16:10:11 +01:00
nou 428f9c360a Small optimization in resample 2024-01-15 08:58:14 +01:00
nou a8a1509db7 Show error message in main window when image fail to load 2024-01-14 14:32:01 +01:00
nou 6539c78c57 Add box resize algorithm 2024-01-14 14:28:28 +01:00
nou 0e0d29320e Set unlimited image size so it doesn't fail to load big images 2024-01-14 14:04:54 +01:00
nou 1efe8e6974 Fix date in meta info 2024-01-11 13:30:30 +01:00
nou dae10182d1 Fix SSE instricts ifdef 2024-01-09 15:40:27 +01:00
nou ed5fc9c1c2 Increase number max preload images to 32 2024-01-08 16:52:46 +01:00
nou cd6a64a98b Additional work on batch processing 2024-01-08 15:44:05 +01:00
nou 67355a82b7 Add bayer mask selection 2024-01-08 15:43:21 +01:00
nou 8fc2078a3a Don't skip images before they load 2024-01-05 13:37:13 +01:00
nou da9b389409 Add slideshow 2024-01-05 13:36:06 +01:00
nou 7818b8d3e9 Fix icon instalation 2023-12-31 16:04:32 +01:00
nou 11294bfcb0 Scripting module 2023-12-31 16:04:16 +01:00
nou faecb385aa Reorganize resources 2023-12-22 11:20:03 +01:00
nou e5be04926b Fix warnings 2023-12-20 11:31:55 +01:00
nou eaf2c7094b Migrate to Qt6 2023-12-20 11:31:51 +01:00
nou aef41f5f6b Fix Qt deprectation warnings 2023-12-18 16:03:04 +01:00
nou 2134f13b06 Add nearest and bicubic filtering 2023-12-18 15:54:15 +01:00
nou 0e9c980325 Add support for CR3 files 2023-11-25 18:06:38 +01:00
nou b9bf6bf183 Fixed scaling for int32 2023-11-21 18:31:07 +01:00
nou 50c070b169 Fix stack size problem on MacOS 2023-11-16 22:13:32 +01:00
nou cfee287bfa Update metainfo 2023-11-16 22:13:25 +01:00
nou 61e0c542f5 Update translations and help 2023-11-16 19:11:36 +01:00
nou a42abb05ea Add scaling for float images that are out of 0.0-1.0 range 2023-11-15 10:14:25 +01:00
nou 5c6df4a59f Optimize calculating stast for debayer 2023-11-15 10:13:49 +01:00
nou 35d5934227 Better stretch non full range images like CR2 2023-11-15 10:12:55 +01:00
nou 8e3c1b35db Remove dead code 2023-11-15 10:02:53 +01:00
nou 544e4abf92 Made unlinked stretch white balancing 2023-11-14 23:47:47 +01:00
nou e97e10fb5b Make STF slider wider 2023-11-14 16:30:57 +01:00
nou 2608a1bc79 Add tooltip with filenames 2023-11-14 16:30:38 +01:00
nou fa69f17e51 Support for unlinked stretch 2023-11-14 12:08:28 +01:00
nou 4a9d720343 Sum all channels histograms 2023-11-14 12:04:55 +01:00
nou d462ece7c9 Improve histogram for 8 bit images 2023-11-13 23:15:34 +01:00
nou 46b0210078 Add histogram 2023-11-13 21:12:23 +01:00
nou 0a803ace10 Prepare for three channels STF 2023-10-10 22:48:40 +02:00
nou 0c2c5f908c Hide fsanitizer behind option 2023-10-10 21:42:26 +02:00
nou c2197298a7 Hide analyze menu 2023-09-30 23:13:11 +02:00
nou e8630330b2 Show stats for each channel 2023-09-30 23:13:02 +02:00
nou 5955a02175 Fix loading RAW files 2023-09-10 22:14:27 +02:00
nou c0b9194ecc Add header files to cmakelists.txt 2023-09-09 17:39:09 +02:00
nou 5f27acbfd1 Add test files 2023-08-29 23:17:16 +02:00
nou f1a2aae9b6 Update LibXISF, fixes in RawImage 2023-08-28 20:38:35 +02:00
nou 9ffbdcee30 Get rid of raw pointers 2023-06-17 21:47:06 +02:00
nou d9b1c253db Move initialization of member variables 2023-06-17 21:45:35 +02:00
nou 7e39304799 Get rid of some explicit new allocation 2023-06-17 20:32:58 +02:00
nou 31cf1ee2b1 Getting rid of opencv 2023-06-16 23:40:11 +02:00
nou ab245f0484 Add false color rendering 2023-06-02 20:41:34 +02:00
nou 77c312800a Update metainfo 2023-04-19 19:07:15 +02:00
nou 21e90b92dc Fix assert lo < hi in std::clamp 2023-04-19 14:33:29 +02:00
nou 2817d3c7c9 Update libXISF 2023-04-12 22:24:45 +02:00
nou a51b0ef02c Floor offset to to prevent half pixel drawing 2023-03-13 22:49:34 +01:00
nou 7b19230366 Fix disrepancy between wheel scroll and bar 2023-03-12 16:44:18 +01:00
nou 26666ee36d Improved zoom and scrolling 2023-03-12 13:45:07 +01:00
nou 74aee15f80 Specify layout index in shader 2023-03-11 13:38:36 +01:00
nou fde1594086 Add file list sorting 2023-03-11 10:41:26 +01:00
nou a9783f6030 Update LibXISF 2023-03-09 18:35:38 +01:00
nou 1ce4f95f53 Release 20230212 2023-02-12 23:02:50 +01:00
nou 1400fd2e32 Fix bug in XISF indexing 2023-02-12 22:59:07 +01:00
nou cc7f56fc53 Change submodule URL 2023-02-10 14:08:37 +01:00
nou 8921ef9c63 Restore accidently removed FITSRecord ctr 2023-02-10 13:45:13 +01:00
nou 576df9c196 Downscale image to max OpenGL texture 2023-02-10 09:11:38 +01:00
nou c47ecbedb8 Replace PCL with LibXISF 2023-02-10 09:10:57 +01:00
nou c7f4e3747a Fix initialization of SATURATION settings 2023-01-12 09:47:41 +01:00
nou 304cd33f34 Fix white balance uninitialized at start 2023-01-11 00:49:26 +01:00
nou abc813ddbb Fix exceptions and errors in analyzing code 2023-01-01 19:04:23 +01:00
nou 88f449d971 Add makeCurrent to all methods that calls OpenGL 2022-12-29 23:12:06 +01:00
nou 295ddb8daf Don't create debug context 2022-12-29 21:56:23 +01:00
nou 1a220bc3ed Update metainfo 2022-12-28 14:59:17 +01:00
nou f67539a3a1 Update translations 2022-12-28 14:51:45 +01:00
nou 468bcb5abb Add saturation statistic 2022-12-28 14:43:47 +01:00
nou fd49ba9a44 CSV export 2022-12-28 13:24:05 +01:00
nou 22e3b06fdd Fix potentional race conditions 2022-12-28 11:33:26 +01:00
nou 01febbf421 Fix invalid query when no column is selected 2022-12-28 11:17:36 +01:00
nou 7690496cf5 Load XISF::ReadImageProperties 2022-12-26 18:07:16 +01:00
nou 743a5f50c4 Disable manual mipmap generation on ATI cards 2022-12-26 10:19:45 +01:00
nou eac534352f Tidy up some debug outputs 2022-12-26 10:19:20 +01:00
nou 57bdc74ef6 Get rid of QRegExp 2022-12-26 10:13:24 +01:00
nou fd1fd7ff08 Get rid of fullscreen mode 2022-12-25 19:34:09 +01:00
nou c1aca3ca65 Add fine tune for STF slider 2022-12-22 12:45:47 +01:00
nou 5cc8fdd83d Simple grey world white balance 2022-12-20 22:27:15 +01:00
nou 66e13529be Allow change of preload without restart 2022-12-18 10:18:01 +01:00
nou e1bed8e1cb Allow change of thumbnail size without restart 2022-12-18 00:17:28 +01:00
nou 151f521688 Set image width and height for XISF 2022-12-17 09:48:35 +01:00
nou 926647e1a7 Don't do unecessary color profile conversion 2022-12-17 09:47:38 +01:00
nou 71fc1f2bd1 Release 20221215 2022-12-15 20:54:39 +01:00
nou f1ff04382b Add option to not use native file dialogs
Thanks to Patrick Chevalley for updated french tranlation
2022-12-15 20:36:19 +01:00
nou ad91adf1d9 Implement workaround for flatpak QFile::moveToTrash 2022-12-15 17:26:16 +01:00
nou b7369c2501 Remove unused variables in debayer shader 2022-12-15 00:25:00 +01:00
nou 79ed6b2059 Fix error in slovak translation 2022-12-15 00:10:52 +01:00
nou 380974a088 Allow saving debayered image 2022-12-15 00:03:29 +01:00
nou b1ad56ca1f Fix debayer shader 2022-12-15 00:03:14 +01:00
nou 58abef5a72 Update metainfo 2022-12-14 22:00:07 +01:00
nou 5427ff57cb Change superpixel tooltip 2022-12-14 21:58:24 +01:00
nou 6a2fa3f656 Update translation 2022-12-14 21:51:19 +01:00
nou c62ec7db8c Add move to trash action 2022-12-14 21:51:05 +01:00
nou d5eb0fdce5 Change key shortcuts 2022-12-14 21:50:30 +01:00
nou 6d25919e1f Add image formats to help 2022-12-14 21:50:05 +01:00
nou 26d1af6077 Add debayer 2022-12-14 21:18:25 +01:00
nou 44d8a8b856 Fix invert button 2022-12-14 17:42:13 +01:00
nou dab6c1f79d Add All files filter to open dialog 2022-12-14 17:16:32 +01:00
nou ce6a4cc40c Refresh dir when show hidden files is toggled 2022-12-13 21:31:23 +01:00
nou 0368c1f1dc Update metainfo xml 2022-12-10 07:48:17 +01:00
nou a1e98d818b Fix copy on btrfs 2022-12-09 19:58:15 +01:00
nou f3f194bcef Update translation and metainfo 2022-12-09 19:33:26 +01:00
nou efd36f96c3 Use native dialogs 2022-12-09 18:38:07 +01:00
nou 37923b37b3 Add error message for copy/move 2022-12-09 18:36:43 +01:00
nou 900453577e Fix includes 2022-11-28 17:36:37 +01:00
nou 34d466c3e0 Show checker pattern with transparent files 2022-11-28 17:32:23 +01:00
nou 9e98127084 Do gamma conversion manualy
Requesting sRGB capable framebuffer is unreliable
2022-11-28 17:31:50 +01:00
nou ba6062b925 Enale loading all image types that Qt can load 2022-11-27 21:10:43 +01:00
nou 6411b7cd15 Release 20221126 2022-11-26 12:03:36 +01:00
nou 223f7cd0ea Refractor save dialog 2022-11-26 11:02:29 +01:00
nou f8f9ee08b3 Add QFileDialog::DontUseNativeDialog 2022-11-22 11:04:04 +01:00
nou af5aed7ef8 Install metainfo generally 2022-11-21 19:09:19 +01:00
nou 8f5249b142 Add metainfo file 2022-11-21 17:44:48 +01:00
nou a7dc942c62 Add scalable icon 2022-11-21 15:49:09 +01:00
nou 1a1399434b Change domain name 2022-11-21 13:18:46 +01:00
nou be567841bf Workaround in AMD OpenGL driver bug
AMD OpenGL driver on Windows doesn't generate mipmaps for sRGB textures
correctly
2022-10-26 23:32:22 +02:00
nou 62d2671112 Update french translation 2022-10-23 12:11:40 +02:00
nou 1f8923512e Update translations 2022-10-23 10:18:21 +02:00
nou 455c3b2d64 Make it combilable with Qt 5.13 and older 2022-10-23 09:54:23 +02:00
nou 4fe546f0e5 Add support for ICC color profiles 2022-10-18 21:19:05 +02:00
nou 95c6fc5343 Enable sRGB to gamma correct scaling 2022-10-16 11:05:15 +02:00
nou 2bc54ea0cc Fix loading RAW on MacOS
LibRaw object is too big for stack so needs to be on heap
2022-10-15 09:56:14 +02:00
nou be6e472081 Settings dialog 2022-10-10 10:30:25 +02:00
nou 9746f8f653 Add option to show hidden files 2022-08-29 18:37:51 +02:00
nou b51a305c63 Remove unused method 2022-08-29 18:29:00 +02:00
nou 39775b5e98 Scale float images to 0,1 range on load 2022-07-22 11:36:10 +02:00
nou 93b56e2966 Workaround for QTBUG-87332 2022-07-03 13:40:54 +02:00
nou 2e41464ff4 Update build instructions 2022-06-27 10:26:27 +02:00
nou b6ae7d4cdb Update french help, fix few typo. Thanks to Patrick Chevalley 2022-06-24 21:14:08 +02:00
nou 1bd48e8fb4 Refres database table when indexing is done 2022-06-24 18:30:28 +02:00
nou 1d65eda490 Search with CRVAL# 2022-06-24 18:06:26 +02:00
nou 97346df596 Update help 2022-06-24 18:05:33 +02:00
nou a157b274a2 Save to database CRVALi 2022-06-23 16:57:00 +02:00
nou 6466702819 Set correct type to vertex attribute 2022-06-22 23:43:56 +02:00
nou b4ea65b42a Upload sizes to OpenGL only once per draw
Should fix MacOS issue
2022-06-22 23:24:29 +02:00
nou 1682de4e1b Update translations 2022-06-22 23:01:35 +02:00
nou 00872b31df Add icon for MacOS 2022-06-21 09:12:26 +02:00
nou 2884787916 Changes to build on MacOS 2022-06-20 23:52:09 +02:00
nou 86ea9fc137 Add MacOS PCL libs 2022-06-20 23:36:31 +02:00
nou 67199a033d Better status bar 2022-06-17 13:24:52 +02:00
nou 0f182900c2 Fix build on older gcc 2022-06-17 09:54:50 +02:00
nou 19ed5ae1a4 Better handling of FITS records 2022-06-17 00:31:27 +02:00
nou 46215c7a7d Workaround for incorect handling of PV1_2 2022-06-16 23:46:54 +02:00
nou c346487504 Add parsing WCS info from XISF 2022-06-16 23:44:28 +02:00
nou 5b6fead6f1 Fix issue with numeric values in XISF FITS header 2022-06-15 08:55:44 +02:00
nou 3e94aa0eda Add search by RA and DEC point 2022-06-14 22:46:40 +02:00
nou 08e70cdb52 Calculate bounds on indexing 2022-06-14 21:44:32 +02:00
nou 04e587b51c Add WCSData::calculateBounds 2022-06-13 23:28:39 +02:00
nou 42dd55244a Add wcslib as lib name 2022-06-13 18:50:57 +02:00
nou 6b9ea5e4b9 Add support for WCS 2022-06-13 18:02:58 +02:00
nou 701a425cc7 Add support for 16 bit PNG images 2022-06-11 22:39:06 +02:00
nou 9cd2ae14b3 Add status bar with color value 2022-06-11 17:19:03 +02:00
nou f7e4e1874f Proper filter setting 2022-06-11 14:10:07 +02:00
nou e6749fc487 Move shaders to subdirectory 2022-06-11 12:27:15 +02:00
nou dc6aa6baa8 Fix bug with wayland backend 2022-06-09 23:30:23 +02:00
nou c8a70d22f8 Show marked files in file list bold 2022-06-04 15:59:51 +02:00
nou dbb533176c Remove unecessary call 2022-06-04 08:10:47 +02:00
nou 032f5b0577 Improve file selection in file system widget 2022-06-03 10:51:51 +02:00
447 changed files with 25769 additions and 213239 deletions
+3
View File
@@ -0,0 +1,3 @@
[submodule "libXISF"]
path = libXISF
url = https://gitea.nouspiro.space/nou/libXISF.git
-43
View File
@@ -1,43 +0,0 @@
*******************************************************************************
PixInsight Class Library License Version 1.0
*******************************************************************************
Copyright (c) 2003-2021, Pleiades Astrophoto S.L. All Rights Reserved.
Redistribution and use in both source and binary forms, with or without
modification, is permitted provided that the following conditions are met:
1. All redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. All redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names of
their contributors, may be used to endorse or promote products derived from
this software without specific prior written permission. For written
permission, please contact info@pixinsight.com.
4. All products derived from this software, in any form whatsoever, must
reproduce the following acknowledgment in the end-user documentation and/or
other materials provided with the product:
"This product is based on software from the PixInsight project, developed by
Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
Alternatively, if that is where third-party acknowledgments normally appear,
this acknowledgment must be reproduced in the product itself.
THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS INTERRUPTION; PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE, DATA OR PROFITS) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************
-509
View File
@@ -1,509 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/APASSDatabaseFile.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_APASSDatabaseFile_h
#define __PCL_APASSDatabaseFile_h
/// \file pcl/APASSDatabaseFile.h
#include <pcl/Defs.h>
#include <pcl/ElapsedTime.h>
#include <pcl/Flags.h>
#include <pcl/StarDatabaseFile.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::APASSStarFlag
* \brief Data availability and quality flags for APASS star data.
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>APASSStarFlag::NoMag_V</td> <td>No Johnson V magnitude available.</td></tr>
* <tr><td>APASSStarFlag::NoMag_B</td> <td>No Johnson B magnitude available.</td></tr>
* <tr><td>APASSStarFlag::NoMag_u</td> <td>No Sloan u' magnitude available (APASS DR10 only).</td></tr>
* <tr><td>APASSStarFlag::NoMag_g</td> <td>No Sloan g' magnitude available.</td></tr>
* <tr><td>APASSStarFlag::NoMag_r</td> <td>No Sloan r' magnitude available.</td></tr>
* <tr><td>APASSStarFlag::NoMag_i</td> <td>No Sloan i' magnitude available.</td></tr>
* <tr><td>APASSStarFlag::NoMag_z_s</td> <td>No Sloan z_s magnitude available (APASS DR10 only).</td></tr>
* <tr><td>APASSStarFlag::NoMag_Y</td> <td>No Sloan Y magnitude available (APASS DR10 only).</td></tr>
* <tr><td>APASSStarFlag::PosErrorHigh</td> <td>Uncertainty in right ascension or declination greater than 0.75 arcseconds.</td></tr>
* </table>
*
* \ingroup point_source_databases
*/
namespace APASSStarFlag
{
enum mask_type
{
NoMag_V = 0x0001,
NoMag_B = 0x0002,
NoMag_u = 0x0004,
NoMag_g = 0x0008,
NoMag_r = 0x0010,
NoMag_i = 0x0020,
NoMag_z_s = 0x0040,
NoMag_Y = 0x0080,
PosErrorHigh = 0x0100
};
}
// ----------------------------------------------------------------------------
/*!
* \struct APASSStarData
* \brief Star data structure for APASS catalog search operations.
*
* \ingroup point_source_databases
*/
struct PCL_CLASS APASSStarData
{
double ra = 0; //!< Right ascension in degrees, in the range [0,360).
double dec = 0; //!< Declination in degrees, in the range [-90,+90].
float mag_V = 0; //!< Magnitude in Johnson V (Vega system).
float mag_B = 0; //!< Magnitude in Johnson B (Vega system).
float mag_u = 0; //!< Magnitude in Sloan u' (AB system) (APASS DR10 only).
float mag_g = 0; //!< Magnitude in Sloan g' (AB system).
float mag_r = 0; //!< Magnitude in Sloan r' (AB system).
float mag_i = 0; //!< Magnitude in Sloan i' (AB system).
float mag_z_s = 0; //!< Magnitude in Sloan z_s (AB system) (APASS DR10 only).
float mag_Y = 0; //!< Magnitude in Sloan Y (AB system) (APASS DR10 only).
float err_V = 0; //!< Uncertainty in mag_V.
float err_B = 0; //!< Uncertainty in mag_B.
float err_u = 0; //!< Uncertainty in mag_u (APASS DR10 only).
float err_g = 0; //!< Uncertainty in mag_g.
float err_r = 0; //!< Uncertainty in mag_r.
float err_i = 0; //!< Uncertainty in mag_i.
float err_z_s = 0; //!< Uncertainty in mag_z_s (APASS DR10 only).
float err_Y = 0; //!< Uncertainty in mag_Y (APASS DR10 only).
uint16 flags = 0u; //!< Data availability and quality flags. See the APASSStarFlag namespace.
};
// ----------------------------------------------------------------------------
/*!
* \struct pcl::APASSSearchData
* \brief Data items and parameters for APASS catalog search operations.
*
* \ingroup point_source_databases
*/
typedef XPSD::SearchData<APASSStarData> APASSSearchData;
// ----------------------------------------------------------------------------
/*!
* \class APASSDatabaseFile
* \brief APASS catalog star database file (XPSD format).
*
* This class implements an interface to XPSD files serializing encoded APASS
* star data. As of writing this documentation (December 2020), APASS DR9 and
* DR10 are supported and have been implemented.
*
* The most important functionality of this class is performing fast indexed
* search operations to retrieve point source data for APASS stars matching a
* set of user-defined criteria. See the APASSDatabaseFile::Search() member
* function and the APASSSearchData structure for detailed information.
*
* This implementation provides the following data for the complete APASS DR9
* and DR10 catalogs:
*
* \li Source positions.
* \li Magnitudes on the Johnson V and B bands (Vega system) and Sloan u', g',
* r', i', z_s and Y magnitudes (AB system).
* \li Data availability and quality flags.
*
* \b References
*
* \li APASS: The AAVSO Photometric All-Sky Survey:
* https://www.aavso.org/apass
*
* \b Credits
*
* This work makes use of data from the AAVSO Photometric All Sky Survey, whose
* funding has been provided by the Robert Martin Ayers Sciences Fund and from
* the NSF (AST-1412587).
*
* \sa StarDatabaseFile, GaiaDatabaseFile
* \ingroup point_source_databases
*/
class PCL_CLASS APASSDatabaseFile : public StarDatabaseFile
{
public:
/*!
* Default constructor.
*
* Constructs an invalid instance that cannot be used until initialized by
* calling the Open() member function.
*/
APASSDatabaseFile() = default;
/*!
* Constructs a &APASSDatabaseFile instance initialized from the specified
* point source database file in XPSD format. As of writing this
* documentation (December 2020), The APASS DR9 and DR10 catalogs are
* available.
*
* In the event of errors or invalid data, this constructor will throw the
* appropriate Error exception.
*/
APASSDatabaseFile( const String& filePath )
: StarDatabaseFile( filePath )
{
static_assert( sizeof( EncodedDR9StarData ) == 32, "Invalid sizeof( APASSDatabaseFile::EncodedDR9StarData )" );
static_assert( sizeof( EncodedDR10StarData ) == 36, "Invalid sizeof( APASSDatabaseFile::EncodedDR10StarData )" );
if ( Metadata().databaseIdentifier == "APASSDR9" )
{
m_dr = "DR9";
m_decoder = &APASSDatabaseFile::GetEncodedDR9Data;
}
else if ( Metadata().databaseIdentifier == "APASSDR10" )
{
m_dr = "DR10";
m_decoder = &APASSDatabaseFile::GetEncodedDR10Data;
}
else
throw Error( "Invalid or unsupported APASS database file with unknown identifier '"
+ Metadata().databaseIdentifier + "': " + filePath );
}
/*!
* Move assignment operator. Returns a reference to this object.
*/
APASSDatabaseFile& operator =( APASSDatabaseFile&& ) = default;
/*!
* Deleted copy constructor. %APASSDatabaseFile instances are unique,
* hence cannot be copied.
*/
APASSDatabaseFile( const APASSDatabaseFile& ) = delete;
/*!
* Deleted copy assignment operator. %APASSDatabaseFile instances are
* unique, hence cannot be copied.
*/
APASSDatabaseFile& operator =( const APASSDatabaseFile& ) = delete;
/*!
* Performs a search operation for point sources matching the specified
* criteria.
*
* This member function performs a fast indexed search for point sources in
* this database file matching the criteria defined in the specified \a data
* structure. See the APASSSearchData structure for detailed information on
* search parameters and output data.
*
* Summarily, search criteria include:
*
* \li The region of the sky where point sources will be searched for. This
* region is defined by the equatorial coordinates of a field center and a
* field radius.
*
* \li An optional range of magnitudes.
*
* \li Optional inclusion/exclusion flags.
*
* \li An optional limit for the number of sources included in the search
* result.
*
* The result of the search operation is also returned in the specified
* \a data structure, including, among others, the following items:
*
* \li The list of point sources found.
*
* \li Instrumentation items for performance analysis, including: total
* search time, time used for I/O operations, total I/O operations, time
* used for data decoding, and time used for data decompression.
*/
void Search( APASSSearchData& data ) const
{
ElapsedTime T;
for ( const XPSD::IndexTree& tree : m_index )
tree.Search( data.centerRA, data.centerDec, data.radius, &data );
data.timeTotal += T();
}
/*!
* Returns the name of the APASS data release corresponding to the data
* available in this database file. As of writing this documentation
* (December 2020), this member function can return either "DR9" or "DR10".
*/
const IsoString& DataRelease() const
{
return m_dr;
}
private:
IsoString m_dr; // data release, one of "DR9", "DR10"
typedef void (APASSDatabaseFile::*star_decoder)( const ByteArray&, const XPSD::IndexTree&, const XPSD::IndexNode&, void* ) const;
star_decoder m_decoder = nullptr;
#pragma pack(push, 1)
/*
* Encoded DR9 star record (32 bytes uncompressed).
*/
struct EncodedDR9StarData
{
// Projected coordinates relative to the origin of the parent quadtree
// node, in mas units.
uint32 dx;
uint32 dy;
// Magnitudes in 0.001 mag units, encoded as (mag + 1.5)*1000.
uint16 mag_V;
uint16 mag_B;
uint16 mag_g;
uint16 mag_r;
uint16 mag_i;
// Magnitude uncertainties in 0.001 mag units.
uint16 err_V;
uint16 err_B;
uint16 err_g;
uint16 err_r;
uint16 err_i;
// Right ascension correction for high declinations, in 0.1 mas units.
int16 dra;
// Data availability and quality flags.
uint16 flags;
};
/*
* Encoded DR10 star record (36 bytes uncompressed).
*/
struct EncodedDR10StarData
{
// Projected coordinates relative to the origin of the parent quadtree
// node, in mas units.
uint32 dx;
uint32 dy;
// Magnitudes in 0.001 mag units, encoded as (mag + 1.5)*1000.
uint16 mag_V;
uint16 mag_B;
// uint16 mag_u;
uint16 mag_g;
uint16 mag_r;
uint16 mag_i;
uint16 mag_z_s;
// uint16 mag_Y;
// Magnitude uncertainties in 0.001 mag units.
uint16 err_V;
uint16 err_B;
// uint16 err_u;
uint16 err_g;
uint16 err_r;
uint16 err_i;
uint16 err_z_s;
// uint16 err_Y;
// Right ascension correction for high declinations, in 0.1 mas units.
int16 dra;
// Data availability and quality flags.
uint16 flags;
};
#pragma pack(pop)
void LoadData( void* block, uint64 offset, uint32 size, void* searchData ) const override
{
ElapsedTime T;
StarDatabaseFile::LoadData( block, offset, size, searchData );
reinterpret_cast<APASSSearchData*>( searchData )->timeIO += T();
++reinterpret_cast<APASSSearchData*>( searchData )->countIO;
}
void Uncompress( ByteArray& block, uint32 uncompressedSize, void* searchData ) const override
{
ElapsedTime T;
StarDatabaseFile::Uncompress( block, uncompressedSize, searchData );
reinterpret_cast<APASSSearchData*>( searchData )->timeUncompress += T();
}
void GetEncodedData( const ByteArray& data, const XPSD::IndexTree& tree, const XPSD::IndexNode& node, void* searchData ) const override
{
(this->*m_decoder)( data, tree, node, searchData );
}
void GetEncodedDR9Data( const ByteArray& data, const XPSD::IndexTree& tree, const XPSD::IndexNode& node, void* searchData ) const
{
ElapsedTime T;
APASSSearchData* search = reinterpret_cast<APASSSearchData*>( searchData );
double r = Rad( search->radius );
const EncodedDR9StarData* S = reinterpret_cast<const EncodedDR9StarData*>( data.Begin() );
int count = int( data.Size() / sizeof( EncodedDR9StarData ) );
int matched = 0;
for ( int i = 0; i < count; ++i, ++S )
if ( search->requiredFlags == 0 || (S->flags & search->requiredFlags) == search->requiredFlags )
if ( search->inclusionFlags == 0 || (S->flags & search->inclusionFlags) != 0 )
if ( search->exclusionFlags == 0 || (S->flags & search->exclusionFlags) == 0 )
{
float mag_V = 0.001*S->mag_V - 1.5;
if ( mag_V >= search->magnitudeLow )
if ( mag_V <= search->magnitudeHigh )
{
APASSStarData star;
double x = node.x0 + double( S->dx )/3600/1000;
double y = node.y0 + double( S->dy )/3600/1000;
tree.Unproject( star.ra, star.dec, x, y );
if ( unlikely( S->dra != 0 ) )
{
star.ra += double( S->dra )/3600/1000/10;
if ( star.ra < 0 )
star.ra += 360;
else if ( star.ra >= 360 )
star.ra -= 360;
}
if ( Distance( search->centerRA, search->centerDec, star.ra, star.dec ) < r )
{
if ( search->stars.Length() < size_type( search->sourceLimit ) )
{
star.mag_V = mag_V;
star.mag_B = 0.001*S->mag_B - 1.5;
star.mag_g = 0.001*S->mag_g - 1.5;
star.mag_r = 0.001*S->mag_r - 1.5;
star.mag_i = 0.001*S->mag_i - 1.5;
star.err_V = 0.001*S->err_V;
star.err_B = 0.001*S->err_B;
star.err_g = 0.001*S->err_g;
star.err_r = 0.001*S->err_r;
star.err_i = 0.001*S->err_i;
star.flags = S->flags;
search->stars << star;
}
else
++search->excessCount;
++matched;
}
}
}
search->rejectCount += count - matched;
search->timeDecode += T();
}
void GetEncodedDR10Data( const ByteArray& data, const XPSD::IndexTree& tree, const XPSD::IndexNode& node, void* searchData ) const
{
ElapsedTime T;
APASSSearchData* search = reinterpret_cast<APASSSearchData*>( searchData );
double r = Rad( search->radius );
const EncodedDR10StarData* S = reinterpret_cast<const EncodedDR10StarData*>( data.Begin() );
int count = int( data.Size() / sizeof( EncodedDR10StarData ) );
int matched = 0;
for ( int i = 0; i < count; ++i, ++S )
if ( search->requiredFlags == 0 || (S->flags & search->requiredFlags) == search->requiredFlags )
if ( search->inclusionFlags == 0 || (S->flags & search->inclusionFlags) != 0 )
if ( search->exclusionFlags == 0 || (S->flags & search->exclusionFlags) == 0 )
{
float mag_V = 0.001*S->mag_V - 1.5;
if ( mag_V >= search->magnitudeLow )
if ( mag_V <= search->magnitudeHigh )
{
APASSStarData star;
double x = node.x0 + double( S->dx )/3600/1000;
double y = node.y0 + double( S->dy )/3600/1000;
tree.Unproject( star.ra, star.dec, x, y );
if ( unlikely( S->dra != 0 ) )
{
star.ra += double( S->dra )/3600/1000/10;
if ( star.ra < 0 )
star.ra += 360;
else if ( star.ra >= 360 )
star.ra -= 360;
}
if ( Distance( search->centerRA, search->centerDec, star.ra, star.dec ) < r )
{
if ( search->stars.Length() < size_type( search->sourceLimit ) )
{
star.mag_V = mag_V;
star.mag_B = 0.001*S->mag_B - 1.5;
// star.mag_u = 0.001*S->mag_u - 1.5;
star.mag_g = 0.001*S->mag_g - 1.5;
star.mag_r = 0.001*S->mag_r - 1.5;
star.mag_i = 0.001*S->mag_i - 1.5;
star.mag_z_s = 0.001*S->mag_z_s - 1.5;
// star.mag_Y = 0.001*S->mag_Y - 1.5;
star.err_V = 0.001*S->err_V;
star.err_B = 0.001*S->err_B;
// star.err_u = 0.001*S->err_u;
star.err_g = 0.001*S->err_g;
star.err_r = 0.001*S->err_r;
star.err_i = 0.001*S->err_i;
star.err_z_s = 0.001*S->err_z_s;
// star.err_Y = 0.001*S->err_Y;
star.flags = S->flags;
search->stars << star;
}
else
++search->excessCount;
++matched;
}
}
}
search->rejectCount += count - matched;
search->timeDecode += T();
}
friend class APASSDR9DatabaseFileGenerator;
friend class APASSDR10DatabaseFileGenerator;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_APASSDatabaseFile_h
// ----------------------------------------------------------------------------
// EOF pcl/APASSDatabaseFile.h - Released 2022-03-12T18:59:29Z
-686
View File
@@ -1,686 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/ATrousWaveletTransform.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_ATrousWaveletTransform_h
#define __PCL_ATrousWaveletTransform_h
/// \file pcl/ATrousWaveletTransform.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/AutoPointer.h>
#include <pcl/KernelFilter.h>
#include <pcl/RedundantMultiscaleTransform.h>
#include <pcl/SeparableFilter.h>
namespace pcl
{
// ----------------------------------------------------------------------------
class InterlacedTransformation;
/*!
* \class ATrousWaveletTransform
* \brief Discrete isotropic à trous wavelet transform.
*
* The Isotropic Undecimated Wavelet Transform, also known as starlet transform
* or <em>à trous</em> (with holes) wavelet transform, produces a coefficient
* set {w1,w2,...,wN,cN}, where each wj is a set of zero-mean coefficients at
* scale j, which we call <em>detail layer</em>, and cN is a large-scale
* smoothed residual, which we call <em>residual layer</em>. Each layer has the
* same dimensions as the input image, hence the transform is redundant.
*
* The wavelet function in the à trous algorithm is the difference between the
* values of a scaling function F at two successive scales. Using the dyadic
* scaling sequence, the wavelet function can be represented as
* (F(x) - F(x/2)). The scaling function F can be any positive low-pass filter.
*
* The reconstruction algorithm consists of the sum of all wj detail layers
* for 1 <= j <= N, plus the residual layer cN.
*
* \b References
*
* \li Jean-Luc Starck, Fionn Murtagh, Mario Bertero, <em>Handbook of
* Mathematical Methods in Imaging</em>, ch. 34, <em>Starlet Transform in
* Astronomical Data Processing</em>, Springer, 2011, pp. 1489-1531.
*
* \li Starck, J.-L., Murtagh, F. and J. Fadili, A., <em>Sparse %Image and
* Signal Processing: Wavelets, Curvelets, Morphological Diversity</em>,
* Cambridge University Press, 2010.
*
* \li Starck, J.-L., Murtagh, F., <em>Astronomical %Image and Data
* Analysis</em>, Springer, 2002.
*
* \li Jean-Luc Starck, Fionn Murtagh, Albert Bijaoui, <em>%Image processing
* and Data Analysis: The Multiscale Approach</em>, Cambridge University Press,
* 1998.
*
* \b Implementation
*
* In our implementation, each layer in a wavelet transform is a floating-point
* image with the same dimensions as the transformed image. Layers are indexed
* from 0 to N. Layers at indexes from 0 to N-1 are detail layers, whose
* elements are actually wavelet difference coefficients. Pixels in a detail
* layer can be negative, zero or positive real values.
*
* The last layer, at index N, is the large-scale residual layer. Pixels in the
* residual layer image can only be positive or zero real values.
*
* \ingroup multiscale_transforms
*
* \note The StarletTransform class is an alias for %ATrousWaveletTransform.
*/
class PCL_CLASS ATrousWaveletTransform : public RedundantMultiscaleTransform
{
public:
/*!
* Represents a wavelet layer.
*/
typedef RedundantMultiscaleTransform::layer layer;
/*!
* Represents a set of wavelet layers, or wavelet transform.
*/
typedef RedundantMultiscaleTransform::transform transform;
/*!
* Represents a set of layer enabled/disabled states.
*/
typedef RedundantMultiscaleTransform::layer_state_set layer_state_set;
/*!
* \brief The scaling function of a wavelet transform.
*
* A wavelet scaling function can be either a non-separable kernel filter,
* implemented as the KernelFilter class, or a separable filter implemented
* as SeparableFilter.
*
* Separable filters should be better in terms of performance, since
* separable convolution has O(N) complexity, as opposed to O(N^2) for
* non-separable convolution. However, in current PCL versions separable
* convolutions are only faster for relatively large filter sizes as a resut
* of vectorization with SIMD processor instructions. See the
* SeparableConvolution class and the \ref convolution_speed_limits "Helper
* Functions for Selection of Convolution Algorithms" section for more
* information.
*
* \sa KernelFilter, SeparableFilter
*/
struct WaveletScalingFunction
{
AutoPointer<KernelFilter> kernelFilter; //!< Non-separable kernel filter
AutoPointer<SeparableFilter> separableFilter; //!< Separable filter
/*!
* Default constructor. Constructs an uninitialized instance.
*/
WaveletScalingFunction() = default;
/*!
* Non-separable filter constructor. The scaling function will own a
* duplicate of the specified kernel filter.
*/
WaveletScalingFunction( const KernelFilter& f )
{
kernelFilter = f.Clone();
PCL_CHECK( !kernelFilter.IsNull() )
}
/*!
* Separable filter constructor. The scaling function will own a
* duplicate of the specified separable filter.
*/
WaveletScalingFunction( const SeparableFilter& f )
{
separableFilter = f.Clone();
PCL_CHECK( !separableFilter.IsNull() )
}
/*!
* Copy constructor. The scaling function will own a duplicate of the
* kernel or separable filter in the source object.
*/
WaveletScalingFunction( const WaveletScalingFunction& s )
{
if ( !s.kernelFilter.IsNull() )
{
kernelFilter = s.kernelFilter->Clone();
PCL_CHECK( !kernelFilter.IsNull() )
}
if ( !s.separableFilter.IsNull() )
{
separableFilter = s.separableFilter->Clone();
PCL_CHECK( !separableFilter.IsNull() )
}
}
/*!
* Move constructor.
*/
WaveletScalingFunction( WaveletScalingFunction&& s )
: kernelFilter( s.kernelFilter )
, separableFilter( s.separableFilter )
{
}
/*!
* Destroys this scaling function object. Destroys and deallocates the
* existing kernel or separable filter in this object.
*/
virtual ~WaveletScalingFunction()
{
}
/*!
* Copy assignment operator. Returns a reference to this object.
*/
WaveletScalingFunction& operator =( const WaveletScalingFunction& s )
{
if ( s.kernelFilter.IsNull() )
kernelFilter.Destroy();
else
{
kernelFilter = s.kernelFilter->Clone();
PCL_CHECK( !kernelFilter.IsNull() )
}
if ( s.separableFilter.IsNull() )
separableFilter.Destroy();
else
{
separableFilter = s.separableFilter->Clone();
PCL_CHECK( !separableFilter.IsNull() )
}
return *this;
}
/*!
* Move assignment operator. Returns a reference to this object.
*/
WaveletScalingFunction& operator =( WaveletScalingFunction&& ) = default;
/*!
* Returns true if this scaling function is a separable filter; false if
* it is an invalid or non-separable kernel filter.
*/
bool IsSeparable() const
{
return !separableFilter.IsNull() && !separableFilter->IsEmpty();
}
/*!
* Returns true if this scaling function is a non-separable kernel
* filter; false if it is an invalid or separable filter.
*/
bool IsNonseparable() const
{
return !kernelFilter.IsNull() && !kernelFilter->IsEmpty();
}
/*!
* Returns true iff this scaling function is valid, that is, if it owns a
* nonempty filter.
*/
bool IsValid() const
{
return IsSeparable() || IsNonseparable();
}
/*!
* Causes this scaling function to own a duplicate of the specified
* non-separable kernel filter. A previously existing filter is destroyed
* and deallocated.
*/
void Set( const KernelFilter& f )
{
separableFilter.Destroy();
kernelFilter = f.Clone();
PCL_CHECK( !kernelFilter.IsNull() )
}
/*!
* Causes this scaling function to own a duplicate of the specified
* separable filter. A previously existing filter is destroyed and
* deallocated.
*/
void Set( const SeparableFilter& f )
{
kernelFilter.Destroy();
separableFilter = f.Clone();
PCL_CHECK( !separableFilter.IsNull() )
}
/*!
* Destroys the kernel and/or separable filter(s) owned by this object,
* yielding an invalid instance.
*/
void Clear()
{
kernelFilter.Destroy();
separableFilter.Destroy();
}
/*!
* Equality operator. Returns true only if this scaling function is equal
* to another instance.
*/
bool operator ==( const WaveletScalingFunction& other ) const
{
if ( !kernelFilter.IsNull() )
return !other.kernelFilter.IsNull() && *kernelFilter == *other.kernelFilter;
if ( !separableFilter.IsNull() )
return !other.separableFilter.IsNull() && *separableFilter == *other.separableFilter;
return other.kernelFilter.IsNull() && other.separableFilter.IsNull();
}
};
/*!
* Default constructor.
*
* \note This constructor yields an uninitialized instance that cannot be
* used prior to initializing it with a reference to a filter object
* (either KernelFilter or SeparableFilter), which will be used as the
* scaling function of the wavelet transform.
*/
ATrousWaveletTransform() = default;
/*!
* Constructs an %ATrousWaveletTransform instance using the specified
* scaling function.
*
* \param f A wavelet scaling function that can be either a non-separable
* filter (KernelFilter) or a separable filter (SeparableFilter).
*
* \param n Number of wavelet layers. The transform will consist of \a n
* wavelet layers plus a residual layer, i.e. n+1 total layers.
*
* \param d Scaling sequence. If \a d <= 0, the transform will use the
* dyadic sequence: 1, 2, 4, ... 2^i. If \a d > 0, its value is
* the distance in pixels between two successive scales.
*
* The default values for \a n and \a d are 4 and 0, respectively (four
* wavelet layers and the dyadic scaling sequence).
*/
ATrousWaveletTransform( const WaveletScalingFunction& f, int n = 4, int d = 0 )
: RedundantMultiscaleTransform( n, d )
, m_scalingFunction( f )
{
PCL_CHECK( m_scalingFunction.IsValid() )
}
/*!
* Constructs an %ATrousWaveletTransform instance that uses a non-separable
* kernel filter as a scaling function.
*
* \param f Non-separable filter that will be used as the scaling
* function of the transform. Must be a positive, low-pass
* filter function.
*
* \param n Number of wavelet layers. The transform will consist of \a n
* wavelet layers plus a residual layer, i.e. n+1 total layers.
*
* \param d Scaling sequence. If \a d <= 0, the transform will use the
* dyadic sequence: 1, 2, 4, ... 2^i. If \a d > 0, its value is
* the distance in pixels between two successive scales.
*
* The default values for \a n and \a d are 4 and 0, respectively (four
* wavelet layers and the dyadic scaling sequence).
*/
ATrousWaveletTransform( const KernelFilter& f, int n = 4, int d = 0 )
: RedundantMultiscaleTransform( n, d )
, m_scalingFunction( f )
{
PCL_CHECK( m_scalingFunction.IsValid() )
}
/*!
* Constructs an %ATrousWaveletTransform instance that uses a separable
* kernel filter as a scaling function.
*
* \param f Separable filter that will be used as the scaling function of
* the transform. Must be a positive, low-pass filter function.
*
* \param n Number of wavelet layers. The transform will consist of \a n
* wavelet layers plus a residual layer, i.e. n+1 total layers.
*
* \param d Scaling sequence. If \a d <= 0, the transform will use the
* dyadic sequence: 1, 2, 4, ... 2^i. If \a d > 0, its value is
* the distance in pixels between two successive scales.
*
* The default values for \a n and \a d are 4 and 0, respectively (four
* wavelet layers and the dyadic scaling sequence).
*/
ATrousWaveletTransform( const SeparableFilter& f, int n = 4, int d = 0 )
: RedundantMultiscaleTransform( n, d )
, m_scalingFunction( f )
{
PCL_CHECK( m_scalingFunction.IsValid() )
}
/*!
* Copy constructor.
*/
ATrousWaveletTransform( const ATrousWaveletTransform& ) = default;
/*!
* Move constructor.
*/
ATrousWaveletTransform( ATrousWaveletTransform&& ) = default;
/*!
* Destroys this %ATrousWaveletTransform object. All existing wavelet layers
* and the internal scaling function filter object are destroyed and
* deallocated.
*/
virtual ~ATrousWaveletTransform()
{
}
/*!
* Copy assignment operator. Returns a reference to this object.
*/
ATrousWaveletTransform& operator =( const ATrousWaveletTransform& ) = default;
/*!
* Move assignment operator. Returns a reference to this object.
*/
ATrousWaveletTransform& operator =( ATrousWaveletTransform&& ) = default;
/*!
* Returns a reference to the (immutable) scaling function used by this
* wavelet transform.
*/
const WaveletScalingFunction& ScalingFunction() const
{
return m_scalingFunction;
}
/*!
* Sets a new scaling function \a f for this wavelet transform.
*
* \note As a consequence of calling this member function, all existing
* wavelet layers in this transform are destroyed.
*/
void SetScalingFunction( const WaveletScalingFunction& f )
{
DestroyLayers();
m_scalingFunction = f;
PCL_CHECK( m_scalingFunction.IsValid() )
}
/*!
* Sets a non-separable kernel filter as the scaling function \a f used by
* this wavelet transform.
*
* \note As a consequence of calling this member function, all existing
* wavelet layers in this transform are destroyed.
*/
void SetScalingFunction( const KernelFilter& f )
{
DestroyLayers();
m_scalingFunction.Set( f );
PCL_CHECK( m_scalingFunction.IsValid() )
}
/*!
* Sets a separable kernel filter as the scaling function \a f used by this
* wavelet transform.
*
* \note As a consequence of calling this member function, all existing
* wavelet layers in this transform are destroyed.
*/
void SetScalingFunction( const SeparableFilter& f )
{
DestroyLayers();
m_scalingFunction.Set( f );
PCL_CHECK( m_scalingFunction.IsValid() )
}
/*!
* Estimation of the standard deviation of the noise, assuming a Gaussian
* noise distribution. This routine implements the k-sigma clipping noise
* estimation algorithm described by Starck et al. (see the references in
* the detailed documentation for this class). The algorithm is described
* for example in <em>Astronomical %Image and Data Analysis</em>, pp. 37-38.
*
* This routine can be used to provide an initial estimate to the more
* accurate <em>multiresolution support noise estimation algorithm</em>,
* implemented as the NoiseMRS() routine. When used with a relative error
* bound (see the \a eps parameter), this routine can easily yield noise
* estimates to within 1% accuracy.
*
* \param j Wavelet layer index (zero-based). The default index is 0.
*
* \param k Clipping multiplier in sigma units. The default value is 3.
*
* \param eps Fractional relative accuracy. If this parameter is greater
* than zero, the algorithm will iterate until the difference
* between two successive iterations is less than \a eps. The
* default value is 0.01, so this routine iterates to achieve an
* estimate to within 1% accuracy.
*
* \param n Maximum number of iterations. When \a eps is zero, this is
* the fixed number of iterations of the noise estimation
* algorithm. Three iterations usually give an estimate to
* within 5% accuracy. 5 or 6 iterations can provide 1% accuracy
* in most cases. When \a eps is greater than zero, this
* parameter works as a security limit to prevent too long
* execution times when convergence is slow (which shouldn't
* happen under normal conditions). The default value is 10.
*
* \param[out] N Pointer to a variable that will receive the total number
* of pixels tagged as noise during the noise evaluation
* process. This pointer can legally be \c nullptr, which is
* also the default value of this parameter.
*
* Returns the estimated standard deviation of the noise in the specified
* scale \a j of the wavelet transform after a relative \a eps accuracy has
* been reached or \a n sigma clipping iterations have been performed,
* whichever happens first.
*
* The returned value must be scaled by the standard deviation of the
* Gaussian noise at the specified wavelet scale. The scaling factor depends
* on the wavelet scaling function used to perform the wavelet decomposition
* and must be coherent with the transform performed by this object.
*
* If this %ATrousWaveletTransform object does not contain a valid wavelet
* transform, or if the specified wavelet layer has been deleted, this
* routine throws an Error exception.
*/
double NoiseKSigma( int j = 0, float k = 3,
float eps = 0.01, int n = 10, size_type* N = nullptr ) const;
/*!
* Estimation of the standard deviation of the noise, assuming a Gaussian
* noise distribution, for a specified range of pixel values.
*
* This routine implements essentially the same algorithm as its unbounded
* counterpart:
*
* NoiseKSigma( int j, float k, float eps, int n, size_type* N ).
*
* The difference is that this version allows you to specify a valid range
* of pixel values with the \a low, \a high and \a image parameters. The
* standard deviation of the noise will only be computed for those pixels
* whose values in the specified \a image pertain to the range
* (<em>low</em>,<em>high</em>), that is, for every pixel with value \a v in
* \a image such that the condition \a low < \e v < \a high is true.
*
* The specified \a image must be compatible with the wavelet transform. In
* particular, the dimensions of \a image must be identical to those of the
* wavelet layers in this transform; otherwise an Error exception will be
* thrown. For selection of pixels within the specified range, only the
* currently selected channel in \a image will be taken into account.
* Normally, the specified \a image must be the same image that was used to
* compute the current wavelet decomposition in this object.
*
* For detailed information on the rest of parameters, the implemented
* algorithm, and special usage conditions for this routine, refer to the
* documentation for the unbounded version of this member function.
*/
double NoiseKSigma( int j, const ImageVariant& image,
float low = 0.00002F, float high = 0.99998F,
float k = 3, float eps = 0.01, int n = 10, size_type* N = nullptr ) const;
/*!
* Estimation of the standard deviation of the Gaussian noise from the
* multiresolution support. This routine implements the iterative algorithm
* described by Jean-Luc Starck and Fionn Murtagh in their paper
* <em>Automatic Noise Estimation from the Multiresolution Support</em>
* (Publications of the Royal Astronomical Society of the Pacific, vol. 110,
* February 1998, pp. 193-199).
*
* \param image The original image. Normally this image should be the same
* image from which this wavelet transform has been
* calculated.
*
* \param sj Noise standard deviation at each wavelet scale for a
* Gaussian noise distribution with unit sigma. There must be
* at least NumberOfLayers() elements in the array pointed to
* by this parameter.
*
* \param sigma Initial estimate of the noise standard deviation in the
* image. The default value is zero. The best starting value
* is the result of the NoiseKSigma() routine. However, the
* noise estimate provided by NoiseKSigma() is relative to a
* particular wavelet layer, so it must be scaled as
* appropriate to make it coherent with the whole image.
*
* \param k Clipping multiplier in sigma units. The default value is 3.
*
* \param[out] N Pointer to a variable that will receive the total number
* of pixels tagged as noise during the noise evaluation
* process. This pointer can legally be \c nullptr, which is
* also the default value of this parameter.
*
* \param low Lower bound of the sampling range in the normalized [0,1]
* range. Pixel sample values less than or equal to \a low
* will be excluded from the noise evaluation process. The
* default value is 0.00002.
*
* \param high Upper bound of the sampling range in the normalized [0,1]
* range. Pixel sample values greater than or equal to
* \a high will be excluded from the noise evaluation
* process. The default value is 0.99998.
*
* Returns the estimated standard deviation of the noise from the
* multiresolution support, using all wavelet scales available. As long as
* successive noise estimates converge to a stable solution, this routine
* performs the necessary iterations until a relative fractional accuracy of
* 1e-4 is achieved. Normally this requires between 4 and 8 iterations,
* depending on the relation between the noise and significant structures in
* the image.
*
* If no convergence is achieved after a large number of iterations, this
* function returns zero and, if a nonzero N argument pointer is specified,
* sets *N = 0. This should never happen if this wavelet transform defines a
* reasonable number of wavelet layers (4 or 5 layers are recommended) and
* the passed parameters are valid and coherent with the wavelet transform.
*
* If this %ATrousWaveletTransform object does not contain a valid wavelet
* transform, if any wavelet layer has been deleted, or if the specified
* image doesn't have the same geometry as the wavelet layers in this
* transform, this routine throws an Error exception.
*/
double NoiseMRS( const ImageVariant& image, const float sj[],
double sigma = 0, float k = 3, size_type* N = nullptr,
float low = 0.00002F, float high = 0.99998F ) const;
private:
/*
* Wavelet scaling function.
*/
WaveletScalingFunction m_scalingFunction;
/*
* Transform (decomposition)
*/
void Transform( const pcl::Image& ) override;
void Transform( const pcl::DImage& ) override;
void Transform( const pcl::ComplexImage& ) override;
void Transform( const pcl::DComplexImage& ) override;
void Transform( const pcl::UInt8Image& ) override;
void Transform( const pcl::UInt16Image& ) override;
void Transform( const pcl::UInt32Image& ) override;
void ValidateScalingFunction() const;
friend class ATWTDecomposition;
};
// ----------------------------------------------------------------------------
/*!
* \class pcl::StarletTransform
* \brief Starlet wavelet transform, a synonym for ATrousWaveletTransform.
*
* The isotropic stationary wavelet transform known as <em>à trous wavelet
* transform</em> since the early publications of Mallat, Starck and Murtagh in
* the 90's, is now known "officially" as <em>starlet transform</em>, at least
* since 2010's <em>%Sparse %Image and %Signal %Processing</em> book.
*
* \ingroup multiscale_transforms
*/
typedef ATrousWaveletTransform StarletTransform;
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_ATrousWaveletTransform_h
// ----------------------------------------------------------------------------
// EOF pcl/ATrousWaveletTransform.h - Released 2022-03-12T18:59:29Z
File diff suppressed because it is too large Load Diff
-586
View File
@@ -1,586 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Action.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Action_h
#define __PCL_Action_h
/// \file pcl/Action.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/Bitmap.h>
#include <pcl/UIObject.h>
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class ActionInfo
* \brief Provides information about the current state of the core
* application's GUI to module-defined actions.
*
* This structure is passed to the Action::IsEnabled() virtual member function.
* See the description of Action::IsEnabled() for more information.
*
* \sa Action
*/
struct ActionInfo
{
bool isImage : 1; //!< true if there is an active image window and it is not read-locked
bool isCurrentPreview : 1; //!< true if the active view is a preview
bool isColor : 1; //!< true if the active view is a color image; false if it is grayscale
int : 5; // reserved for future use, should be zero
uint8 bitsPerSample : 8; //!< number of bits per sample in the active view's image
bool isFloatSample : 1; //!< true if the active view's image is in floating-point format
bool hasPreviews : 1; //!< true if the active image window has one or more previews defined
bool hasMask : 1; //!< true if the active image window is masked
bool thereAreImages : 1; //!< true if there are one or more image windows currently open
int : 12; // reserved for future use, should be zero
};
// ----------------------------------------------------------------------------
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
// ----------------------------------------------------------------------------
/*!
* \class Action
* \brief Client-side interface to a PixInsight module-defined action object.
*
* Module-defined actions manage integration of external processes and tools
* with the main menu and tool bars of the PixInsight core application.
*
* Integration of actions is governed by two main properties: menu item and
* tool bar.
*
* <b>Menu Item</b>
*
* This is a string indicating a menu item where an action will be integrated
* within the PixInsight's main menu structure.
*
* The menu item string describes a path on PixInsight's main menu structure.
* Multiple menu items can be specified, separated with the ">" character.
*
* If this parameter is an empty string, the newly created action won't be
* integrated with the main menu. This can be useful for actions that only
* respond to keyboard accelerators, or actions that only integrate with tool
* bars (see the Tool Bar section below).
*
* <b>Integrating actions into existing top-level main menu items</b>
*
* "Image >> Geometry > Rotate 180 degrees"
* "View > Memory Status"
*
* The above strings will integrate actions into existing top-level main menu
* items (Image and View, respectively). In the first example, a submenu
* entitled "Geometry" will be created under the Image top-level menu item, if
* it doesn't exist yet. The sequence '>>' can be used to insert a separator
* menu item, as has been done before "Geometry" in the example above. Then a
* new item "Rotate 180 degrees" will be created and associated to the
* corresponding action. Note that in this case the PixInsight core application
* decides where exactly new actions are inserted within existing menu items,
* applying different criteria for each menu. In general, in these cases new
* actions are inserted on a per-module basis, in strict order of creation.
*
* <b>Creating custom top-level main menu items</b>
*
* Custom main menu top-level entries can also be created. For example, the
* following menu item string:
*
* "MyTools > Color Tools > A better color saturation process"
*
* Will create a new custom "MyTools" top-level item in the main menu, if it
* doesn't already exist. Custom top-level main menu items are inserted after
* the standard Process menu item, in strict order of creation. Common sense
* and care must be observed when creating custom top-level menu items. If
* possible, it is always preferable to integrate actions into existing
* top-level items; one must be motivated by a really strong reason to create a
* custom menu.
*
* <b>Tool Bar</b>
*
* This is an optional parameter. This is the name of a tool bar where the
* action will be integrated.
*
* If this string is empty, the action will not be integrated in a tool bar.
* Otherwise, the string must be the name of a tool bar where a new tool button
* will be created and associated to the action.
*
* A standard tool bar name can be used (i.e. View, File, and so on). If the
* specified name does not correspond to an existing tool bar, a new, custom
* tool bar will be created, and a new tool button corresponding to this action
* will be added to it.
*
* The specified tool bar name can start with a ">" character to insert a tool
* bar separator (a vertical or horizontal line, depending on the tool bar's
* orientation) before the newly created tool button.
*/
class PCL_CLASS Action : public UIObject
{
public:
/*!
* Constructs a new %Action object.
*
* \param menuItem Specifies the menu item that will be associated with
* this action.
*
* \param iconSVGFile Path to an existing file in the local file system,
* which must store a valid SVG document defining the icon
* image that will be associated with this action. The SVG
* source code must be encoded in UTF-8. The icon will be
* used for menu items and tool bar buttons associated
* with this action. If this parameter is not specified,
* or if the specified SVG document does not exist, is not
* valid, or cannot be rendered, no icon will be used to
* represent this action.
*
* \param toolBar The name of a tool bar where this action will be
* integrated. If this parameter is not specified, the
* action will not be integrated in a tool bar.
*
* <b>Automatic Resource Location</b>
*
* The specified \a iconSVGFile string can be prefixed with the
* "@module_icons_dir/" special token to let the PixInsight core application
* load the corresponding SVG document automatically from the a standard
* distribution directory. See the documentation for
* MetaProcess::IconImageSVGFile() for complete information.
*
* To learn how the menu item and tool bar parameters work for actions, see
* the description of the Action class.
*/
Action( const String& menuItem,
const String& iconSVGFile = String(), const String& toolBar = String() );
/*!
* Constructs a new %Action object.
*
* \param menuItem Specifies the menu item that will be associated with
* this action.
*
* \param iconSVGsource The source code of a valid SVG document defining
* the icon image that will be associated with this
* action. The SVG source code must be encoded in UTF-8.
* The icon will be used for all menu items and tool bar
* buttons associated with this action. If this parameter
* is not specified, or if the specified SVG document is
* not valid or cannot be rendered, no icon will be used
* to represent this action.
*
* \param toolBar The name of a tool bar where this action will be
* integrated. If this parameter is not specified, the
* action will not be integrated in a tool bar.
*
* \note The unused third \c int parameter serves to distinguish this
* constructor from the other one that takes a file path argument. This is
* necessary because both String and IsoString can be constructed from
* literal \c const \c char* arguments.
*
* To learn how the menu item and tool bar parameters work for actions, see
* the description of the Action class.
*/
Action( const String& menuItem,
const IsoString& iconSVGSource, int, const String& toolBar = String() );
#ifdef __PCL_ACTION_DEPRECATED_CTOR
/*!
* Constructs a new %Action object.
*
* \param menuItem Specifies the menu item that will be associated with
* this action.
*
* \param icon A Bitmap object representing the icon image that will
* be associated with this action. The icon will be used
* for menu items and tool bar buttons. If this parameter
* is not specified, no menu icon will be used and a
* default icon will be assigned automatically for tool
* bar buttons, if necessary.
*
* \param toolBar The name of a tool bar where this action will be
* integrated. If this parameter is not specified, the
* action will not be integrated in a tool bar.
*
* To learn how the menu item and tool bar parameters work for actions, see
* the description of the Action class.
*
* \deprecated This member function has been deprecated since core version
* 1.8.8-6. It is still available for compatibility with existing modules
* that depend on it, but it will be removed in a future version of PCL.
* All newly produced code must use the constructors that define icon images
* in SVG format. Existing modules should also be refactored in the same way
* to support scalable icons.
*/
Action( const String& menuItem,
const Bitmap& icon, const String& toolBar = String() );
#endif // __PCL_ACTION_DEPRECATED_CTOR
/*!
* Move constructor.
*/
Action( Action&& x ) : UIObject( std::move( x ) )
{
}
/*!
* Destroys this %Action object.
*
* This destructor does not destroy the actual action object, which is part
* of the PixInsight core application. Only the managed alias object living
* in the caller module is destroyed.
*/
virtual ~Action()
{
}
/*!
* Move assignment operator. Returns a reference to this object.
*/
Action& operator =( Action&& x )
{
Transfer( x );
return *this;
}
/*!
* Ensures that the server-side object managed by this instance is uniquely
* referenced.
*
* Since actions are unique objects, calling this member function has no
* effect.
*/
void EnsureUnique() override
{
}
/*!
* Returns a reference to a null %Action instance. A null %Action does not
* correspond to an existing action in the PixInsight core application.
*/
static Action& Null();
/*!
* Returns the menu item where this action has been integrated in the main
* menu of the PixInsight core application.
*
* An action's menu item is a read-only property: its value can only be set
* with the constructor. In other words: Once an action has been created,
* its menu text can be freely changed, but it cannot be moved in the main
* menu structure.
*
* \sa MenuText()
*/
String MenuItem() const;
/*!
* Returns the text of the menu item where this action has been integrated
* in the main menu of the PixInsight core application.
*
* \sa SetMenuText(), MenuItem()
*/
String MenuText() const;
/*!
* Changes the text of the menu item where this action has been integrated
* in the main menu of the PixInsight core application.
*
* \param text A string representing the new menu text for this action
* object.
*
* \sa MenuText()
*/
void SetMenuText( const String& text );
/*!
* Returns the name of a tool bar where this action has been integrated in
* the PixInsight core application.
*
* Integration of actions with tool bars is optional. If this action has not
* been integrated in a tool bar, this function returns an empty string.
*
* An action's tool bar is a read-only property whose value can only be set
* with the constructor.
*
* \sa SetToolBar()
*/
String ToolBar() const;
/*!
* Obtains the optional keyboard accelerator associated to this action.
*
* \param[out] keyModifiers Specifies an OR'ed combination of the Shift,
* Control and Alt keys. Use the KeyModifier namespace, defined
* in the pcl/ButtonCodes.h header, to decode this value.
*
* \param[out] keyCode Any valid PCL key code, except those codes
* corresponding to modifier keys or system-managed keys. Use
* the KeyCode namespace, defined in the pcl/KeyCodes.h header,
* to decode the returned value.
*
* If no keyboard accelerator has been associated to this action, zero is
* returned for both parameters.
*
* \sa SetAccelerator(), HasAccelerator(), RemoveAccelerator()
*/
void GetAccelerator( int& keyModifiers, int& keyCode ) const;
/*!
* Changes the keyboard accelerator associated to this action.
*
* \param keyModifiers An OR'ed combination of the Shift, Control and
* Alt keys. Use the KeyModifier namespace, defined in the
* pcl/ButtonCodes.h header, to build this value.
*
* \param keyCode A valid PCL key code, except those codes
* corresponding to modifier keys or system-managed keys. Use
* the KeyCode namespace, defined in the pcl/KeyCodes.h header,
* to build this value. If this parameter is zero, no keyboard
* accelerator will be associated to this action.
*
* \sa GetAccelerator(), HasAccelerator(), RemoveAccelerator()
*/
void SetAccelerator( int keyModifiers, int keyCode );
/*!
* Returns true iff this action has an associated keyboard accelerator.
*
* \sa GetAccelerator(), SetAccelerator(), RemoveAccelerator()
*/
bool HasAccelerator() const
{
int dum, key; GetAccelerator( dum, key ); return key != 0;
}
/*!
* Clears (deactivates) the keyboard accelerator associated to this action,
* if any. This is an overloaded function, provided for convenience. It
* is equivalent to SetAccelerator( 0, 0 ).
*
* \sa GetAccelerator(), SetAccelerator(), HasAccelerator()
*/
void RemoveAccelerator()
{
SetAccelerator( 0, 0 );
}
/*!
* Returns the tool tip text that has been assigned to this action. Tool
* tips are used for tool buttons corresponding to the integration of
* actions in tool bars.
*
* If this action has not been integrated in a tool bar, this function has
* no meaning, and an empty string is always returned.
*
* \sa SetToolTip()
*/
String ToolTip() const;
/*!
* Changes the tool tip text for this action. Tool tips are used for tool
* buttons corresponding to the integration of actions in tool bars.
*
* \param tip A string that represents the new tool tip text for this
* action object.
*
* If this action has not been integrated in a tool bar, this function is
* ignored.
*
* \sa ToolTip()
*/
void SetToolTip( const String& tip );
/*!
* Returns a Bitmap corresponding to the icon that has been assigned to
* this action object. %Action icons are used to render the associated menu
* items and tool bar buttons.
*
* If no icon has been associated to this object, a null Bitmap object is
* returned.
*
* \sa SetIcon()
*/
Bitmap Icon() const;
/*!
* Changes the icon associated with this %Action to an image specified in
* SVG format.
*
* \param svgSource The source code of a valid SVG document defining the
* icon image that will be associated with this action.
* The SVG source code must be encoded in UTF-8.
*
* The new icon will be used for all menu items and tool bar buttons
* associated with this action after calling this function. If an empty
* string is specified, or if the specified SVG document is not valid, no
* icon will be used to represent this action.
*
* \sa SetIconSVGFile()
*/
void SetIconSVG( const IsoString& svgSource );
/*!
* Changes the icon associated with this %Action to an image specified in
* SVG format.
*
* \param filePath Path to an existing file in the local file system,
* which must store a valid SVG document representing the
* icon image that will be associated with this action.
* The SVG source code must be encoded in UTF-8.
*
* The new icon will be used for all menu items and tool bar buttons
* associated with this action after calling this function. If an empty
* string is specified, or if the specified SVG document does not exist or
* is not valid, no icon will be used to represent this action.
*
* <b>Automatic Resource Location</b>
*
* The specified \a filePath string can be prefixed with the
* "@module_icons_dir/" special token to let the PixInsight core application
* load the corresponding SVG document automatically from the a standard
* distribution directory. See the documentation for
* MetaProcess::IconImageSVGFile() for complete information.
*
* \sa SetIconSVG()
*/
void SetIconSVGFile( const String& filePath );
/*!
* Changes the icon associated with this %Action object.
*
* \param icon The new icon Bitmap that will be assigned to this %Action.
*
* The new icon will be used for all menu items and tool bar buttons
* associated with this action after calling this function. If a null bitmap
* is specified, no icon will be used to represent this action.
*
* \deprecated This member function has been deprecated since core version
* 1.8.8-6. It is still available for compatibility with existing modules
* that depend on it, but it will be removed in a future version of PCL.
* All newly produced code must use the SetIconSVG() or SetIconSVGFile()
* member functions, which define action icon images in SVG format. Existing
* modules should be refactored in the same way to support scalable icons.
*
* \sa Icon()
*/
void SetIcon( const Bitmap& icon );
/*!
* Callback routine for this action. This function will be called each time
* this action is activated, either by selecting the associated menu item or
* by clicking the corresponding tool button.
*
* Despite this function has not been formalized as a pure virtual function,
* it is such conceptually, so it must be always reimplemented in descendant
* classes.
*/
virtual void Execute();
/*!
* Returns the current \e enabled \e state of this %Action object.
*
* Disabled actions have their associated menu items and tool bar buttons
* disabled, and cannot be activated by the user.
*
* The PixInsight application will call this function repeatedly to learn
* the current state of this action, with the purpose of keeping the
* associated interface elements up-to-date.
*
* The caller of this function is a specialized idle-priority thread that is
* permanently running in the background. This means that this function will
* not be executed in the core application's main GUI thread, so all code in
* this function must be thread-safe. Reimplementations of this function in
* derived classes should decide the action's current state and return as
* quickly as possible.
*
* An ActionInfo structure is passed to this function, describing the
* current state of the user interface. That description should be used by
* the IsEnabled() function to decide whether this action should be enabled
* or disabled, depending on the current interface context.
*
* \note The default implementation of this function always returns true,
* regardless of the current context. This means that all actions are
* enabled by default.
*
* \sa ActionInfo
*/
virtual bool IsEnabled( ActionInfo info ) const
{
return true;
}
private:
Action( void* h ) : UIObject( h )
{
}
void* CloneHandle() const override;
};
// ----------------------------------------------------------------------------
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
} // pcl
#endif // __PCL_Action_h
// ----------------------------------------------------------------------------
// EOF pcl/Action.h - Released 2022-03-12T18:59:29Z
-216
View File
@@ -1,216 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/AdaptiveLocalFilter.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_AdaptiveLocalFilter_h
#define __PCL_AdaptiveLocalFilter_h
/// \file pcl/AdaptiveLocalFilter.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/ImageTransformation.h>
#include <pcl/ParallelProcess.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class AdaptiveLocalFilter
* \brief Adaptive, local noise reduction filter in the spatial domain.
*
* Implementation of the adaptive, local noise reduction filter in the spatial
* domain as described by González and Woods.
*
* <b>References</b>
*
* R.C. González and R.E. Woods, <em>Digital %Image Processing, Third
* Edition</em>, Pearson / Prentice Hall, 2008. pp 330-332.
*/
class PCL_CLASS AdaptiveLocalFilter : public ImageTransformation,
public ParallelProcess
{
public:
/*!
* Constructs an %AdaptiveLocalFilter instance.
*
* \param sigma Standard deviation or median absolute deviation from the
* median (MAD) of the noise (see the \a useMAD parameter).
* If the MAD is used, the specified \a sigma value must be
* consistent with the standard deviation of a normal
* distribution (typically, the computed MAD estimate must be
* multiplied by 1.4826).
*
* \param size Filter size in pixels. This is the length of a side of the
* square pixel neighborhood used by the adaptive filter. The
* filter size must be an odd number greater than or equal to
* three. If an even size is specified, the smallest odd size
* greater than the specified value will be used. The default
* size is five pixels.
*
* \param useMAD If true, use the median absolute deviation from the median
* (MAD) instead of variance / standard deviation for noise
* estimates. Note that this changes the meaning of the
* \a sigma parameter. The default value is false (variance
* is used by default).
*/
AdaptiveLocalFilter( double sigma, int size = 5, bool useMAD = false )
: m_size( Max( 3, size|1 ) )
, m_sigma( Max( 0.0, sigma ) )
, m_useMAD( useMAD )
{
}
/*!
* Copy constructor.
*/
AdaptiveLocalFilter( const AdaptiveLocalFilter& ) = default;
/*!
* Destroys this %AdaptiveLocalFilter object.
*/
virtual ~AdaptiveLocalFilter()
{
}
/*!
* Returns the filter size in pixels.
*/
int Size() const
{
return m_size;
}
/*!
* Sets the filter \a size in pixels.
*/
void SetSize( int size )
{
PCL_PRECONDITION( size >= 3 )
PCL_PRECONDITION( (size & 1) != 0 )
m_size = Max( 3, size|1 );
}
/*!
* Returns the standard deviation or median absolute deviation from the
* median (MAD) of the noise in this adaptive filter.
*
* The meaning of the returned value depends on whether this filter uses
* variance or MAD for noise estimates --see the UsingMAD() member function
* and the class constructor for more information.
*/
double Sigma() const
{
return m_sigma;
}
/*!
* Sets the standard deviation or median absolute deviation from the median
* (MAD) of the noise in this adaptive filter. The specified \a sigma must
* be a positive, nonzero value (a zero noise value is legal, but the filter
* will obviously have no effect).
*
* The meaning of the specified \a sigma value depends on whether this
* filter uses variance or MAD for noise estimates--see the UsingMAD()
* member function and the class constructor for more information.
*/
void SetSigma( double sigma )
{
PCL_PRECONDITION( sigma >= 0 )
m_sigma = Max( 0.0, sigma );
}
/*!
* Returns true iff this adaptive filter uses median absolute deviation (MAD)
* instead of variance / standard deviation to interpret noise estimates.
*/
bool UsingMAD() const
{
return m_useMAD;
}
/*!
* Sets the way this adaptive filter interprets noise estimates: either as
* the median absolute deviation from the median (MAD) or as the standard
* deviation of the noise in the target image.
*/
void UseMAD( bool useMAD = true )
{
m_useMAD = useMAD;
}
protected:
int m_size; // filter size in pixels.
double m_sigma = 5; // standard deviation of the noise in the target image.
bool m_useMAD = false; // use MAD instead of variance / standard deviation.
/*
* Adaptive local filter in the spatial domain.
*/
void Apply( pcl::Image& ) const override;
void Apply( pcl::DImage& ) const override;
void Apply( pcl::UInt8Image& ) const override;
void Apply( pcl::UInt16Image& ) const override;
void Apply( pcl::UInt32Image& ) const override;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_AdaptiveLocalFilter_h
// ----------------------------------------------------------------------------
// EOF pcl/AdaptiveLocalFilter.h - Released 2022-03-12T18:59:29Z
-322
View File
@@ -1,322 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/AkimaInterpolation.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_AkimaInterpolation_h
#define __PCL_AkimaInterpolation_h
/// \file pcl/AkimaInterpolation.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/UnidimensionalInterpolation.h>
namespace pcl
{
// ----------------------------------------------------------------------------
#define m_x this->m_x
#define m_y this->m_y
/*!
* \class AkimaInterpolation
* \brief Akima subspline interpolation algorithm
*
* <b>References</b>
*
* Hiroshi Akima, <em>A new method of interpolation and smooth curve fitting
* based on local procedures</em>, Journal of the ACM, Vol. 17, No. 4, October
* 1970, pages 589-602.
*
* <b>Implementation</b>
*
* Our implementation is based on the book <em>Numerical Algorithms with
* C</em>, by G. Engeln-Mullges and F. Uhlig (Springer, 1996), section 13.1.
*
* We properly represent corners when a data point lies between two adjacent
* straight lines with different slopes. This means that our implementation
* does not impose continuous differentiability, which deviates from the
* original work by Akima. Supporting the accurate representation of corners
* has several practical advantages in our opinion; one of them is the enhanced
* flexibility for the application of Akima interpolation to graphical
* representations of curves given by a set of prescribed x,y data points.
*
* \sa CubicSplineInterpolation, LinearInterpolation
*/
template <typename T = double>
class PCL_CLASS AkimaInterpolation : public UnidimensionalInterpolation<T>
{
public:
/*!
* Represents a vector of independent and dependent variable values.
*/
typedef typename UnidimensionalInterpolation<T>::vector_type vector_type;
/*!
* Represents a vector of interpolation coefficients.
*/
typedef vector_type coefficient_vector;
/*!
* Constructs an %AkimaInterpolation object.
*/
AkimaInterpolation() = default;
/*!
* Copy constructor.
*/
AkimaInterpolation( const AkimaInterpolation& ) = default;
/*!
* Move constructor.
*/
AkimaInterpolation( AkimaInterpolation&& ) = default;
/*!
* Destroys an %AkimaInterpolation object.
*/
virtual ~AkimaInterpolation()
{
}
/*!
* Initializes a new interpolation.
*
* \param x %Vector of x-values:\n
* \n
* \li If x is not empty: Must be a vector of monotonically increasing,
* distinct values: x[0] < x[1] < ... < x[n-1].\n
* \li If x is empty: The interpolation will use implicit x[i] = i for
* i = {0,1,...,n-1}.\n
*
* \param y %Vector of function values for i = {0,1,...,n-1}.
*
* The length of the \a y vector (and also the length of a nonempty \a x
* vector) must be \e n >= 5. This is because Akima interpolation requires
* at least 4 subintervals.
*/
void Initialize( const vector_type& x, const vector_type& y ) override
{
if ( y.Length() < 5 )
throw Error( "AkimaInterpolation::Initialize(): Less than five data points specified." );
try
{
Clear();
UnidimensionalInterpolation<T>::Initialize( x, y );
int n = m_y.Length();
int N = n-1; // Number of subintervals
m_b = coefficient_vector( N );
m_c = coefficient_vector( N );
m_d = coefficient_vector( N );
// Chordal slopes
coefficient_vector m0( N+4 ); // room for 4 additional prescribed slopes
T* m = m0.At( 2 ); // allow negative subscripts m[-1] and m[-2]
// Akima left-hand slopes to support corners
coefficient_vector tL( n );
// Calculate chordal slopes for each subinterval
if ( m_x )
for ( int i = 0; i < N; ++i )
{
T h = m_x[i+1] - m_x[i];
if ( 1 + h*h == 1 )
throw Error( "AkimaInterpolation::Initialize(): Empty interpolation subinterval(s)." );
m[i] = (m_y[i+1] - m_y[i])/h;
}
else
for ( int i = 0; i < N; ++i )
m[i] = m_y[i+1] - m_y[i];
// Prescribed slopes at ending locations
m[-2 ] = 3*m[ 0] - 2*m[ 1];
m[-1 ] = 2*m[ 0] - m[ 1];
m[ N ] = 2*m[N-1] - m[N-2];
m[N+1] = 3*m[N-1] - 2*m[N-2];
/*
* Akima left-hand and right-hand slopes.
* Right-hand slopes are just the interpolation coefficients bi.
*/
for ( int i = 0; i < n; ++i )
{
T f = Abs( m[i-1] - m[i-2] );
T e = Abs( m[i+1] - m[i] ) + f;
if ( 1 + e != 1 )
{
tL[i] = m[i-1] + f*(m[i] - m[i-1])/e;
if ( i < N )
m_b[i] = tL[i];
}
else
{
tL[i] = m[i-1];
if ( i < N )
m_b[i] = m[i];
}
}
/*
* Interpolation coefficients m_b[i], m_c[i], m_d[i]. 'ai'
* coefficients are the m_y[i] ordinate values.
*/
for ( int i = 0; i < N; ++i )
{
m_c[i] = 3*m[i] - 2*m_b[i] - tL[i+1];
m_d[i] = m_b[i] + tL[i+1] - 2*m[i];
if ( m_x )
{
T h = m_x[i+1] - m_x[i];
m_c[i] /= h;
m_d[i] /= h*h;
}
}
}
catch ( ... )
{
Clear();
throw;
}
}
/*!
* Returns an interpolated function value at \a x location.
*/
PCL_HOT_FUNCTION
double operator()( double x ) const override
{
PCL_PRECONDITION( IsValid() )
/*
* Find the subinterval i0 such that m_x[i0] <= x < m_x[i0+1].
* Find the distance dx = x - m_x[i], or dx = x - i for implicit x = {0,1,...n-1}.
*/
int i0;
double dx;
if ( m_x )
{
i0 = 0;
int i1 = m_x.Length() - 1;
while ( i1-i0 > 1 )
{
int im = (i0 + i1) >> 1;
if ( x < m_x[im] )
i1 = im;
else
i0 = im;
}
dx = x - double( m_x[i0] );
}
else
{
if ( x <= 0 )
return m_y[0];
if ( x >= m_y.Length()-1 )
return m_y[m_y.Length()-1];
i0 = TruncInt( x );
dx = x - i0;
}
/*
* Use a Horner scheme to calculate b[i]*dx + c[i]*dx^2 + d[i]*dx^3.
*/
return m_y[i0] + dx*(m_b[i0] + dx*(m_c[i0] + dx*m_d[i0]));
}
/*!
* Frees internal data structures in this AkimaInterpolation object.
*/
void Clear() override
{
m_b.Clear();
m_c.Clear();
m_d.Clear();
UnidimensionalInterpolation<T>::Clear();
}
/*!
* Returns true iff this interpolation is valid, i.e. if it has been
* correctly initialized and is ready to interpolate function values.
*/
bool IsValid() const override
{
return m_b && m_c && m_d;
}
protected:
/*
* Interpolating coefficients for each subinterval.
* The coefficients for dx^0 are the input ordinate values in the m_y vector.
*/
coefficient_vector m_b; // coefficients for dx^1
coefficient_vector m_c; // coefficients for dx^2
coefficient_vector m_d; // coefficients for dx^3
};
#undef m_x
#undef m_y
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_AkimaInterpolation_h
// ----------------------------------------------------------------------------
// EOF pcl/AkimaInterpolation.h - Released 2022-03-12T18:59:29Z
-659
View File
@@ -1,659 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Algebra.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Algebra_h
#define __PCL_Algebra_h
/// \file pcl/Algebra.h
#include <pcl/Defs.h>
#include <pcl/Matrix.h>
#include <pcl/Vector.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \defgroup in_place_gauss_jordan In-Place Gauss-Jordan Solvers
*/
/*!
* Solution to the linear system A*X = B
*
* On output, A is replaced by its inverse matrix and B is the set of solution
* vectors X.
*
* This is an overloaded function for the Matrix type, which is a template
* instantiation of GenericMatrix for double.
*
* \ingroup in_place_gauss_jordan
*/
void PCL_FUNC InPlaceGaussJordan( Matrix& A, Matrix& B );
/*!
* Solution to the linear system A*X = B
*
* On output, A is replaced by its inverse matrix and B is the set of solution
* vectors X.
*
* This is an overloaded function for the FMatrix type, which is a template
* instantiation of GenericMatrix for float.
*
* \ingroup in_place_gauss_jordan
*/
void PCL_FUNC InPlaceGaussJordan( FMatrix& A, FMatrix& B );
/*!
* \class GenericGaussJordan
* \brief Generic Gauss-Jordan linear system solver.
*/
template <typename T>
class PCL_CLASS GenericGaussJordan
{
public:
/*!
* Represents a matrix involved in the solution of a linear system.
*/
typedef GenericMatrix<T> matrix;
/*!
* Represents a matrix element.
*/
typedef typename matrix::element matrix_element;
/*!
* Inverse matrix
*/
matrix Ai; // Inverse matrix
/*!
* Solution vectors
*/
matrix X; // Solution vectors
/*!
* Solution to the linear system A*X = B
*
* This constructor replaces the Ai member of this object with the inverse
* matrix of \a A, and the X member with the set of solution vectors.
*/
GenericGaussJordan( const matrix& A, const matrix& B )
{
Ai = A;
X = B;
InPlaceGaussJordan( Ai, X );
}
};
/*!
* \class GaussJordan
* \brief Gauss-Jordan linear system solver for Matrix objects.
*
* %GaussJordan is a template instantiation of GenericGaussJordan for the
* double type. %GaussJordan works with Matrix objects. %Matrix is a template
* instantiation of GenericMatrix for double.
*/
class PCL_CLASS GaussJordan : public GenericGaussJordan<double>
{
public:
/*!
* Identifies the parent template class, which implements the underlying
* algorithm for this class.
*/
typedef GenericGaussJordan<double> algorithm_implementation;
/*!
* Represents a matrix involved in the solution of a linear system.
*/
typedef algorithm_implementation::matrix matrix;
/*!
* Represents a matrix element.
*/
typedef matrix::element matrix_element;
/*!
* Solution to the linear system A*X = B
*
* This constructor replaces the Ai member of this object with the inverse
* matrix of \a A, and the X member with the set of solution vectors.
*/
GaussJordan( const Matrix& A, const Matrix& B )
: algorithm_implementation( A, B )
{
}
};
/*!
* \class FGaussJordan
* \brief Gauss-Jordan linear system solver for FMatrix objects.
*
* %FGaussJordan is a template instantiation of GenericGaussJordan for the
* float type. %FGaussJordan works with FMatrix objects. %FMatrix is a template
* instantiation of GenericMatrix for float.
*/
class PCL_CLASS FGaussJordan : public GenericGaussJordan<float>
{
public:
/*!
* Identifies the parent template class, which implements the underlying
* algorithm for this class.
*/
typedef GenericGaussJordan<float> algorithm_implementation;
/*!
* Represents a matrix involved in the solution of a linear system.
*/
typedef algorithm_implementation::matrix matrix;
/*!
* Represents a matrix element.
*/
typedef matrix::element matrix_element;
/*!
* Solution to the linear system A*X = B
*
* This constructor replaces the Ai member of this object with the inverse
* matrix of \a A, and the X member with the set of solution vectors.
*/
FGaussJordan( const FMatrix& A, const FMatrix& B )
: algorithm_implementation( A, B )
{
}
};
// ----------------------------------------------------------------------------
void PCL_FUNC InPlaceSVDImplementation( Matrix&, Vector&, Matrix& );
void PCL_FUNC InPlaceSVDImplementation( FMatrix&, FVector&, FMatrix& );
/*!
* \class GenericInPlaceSVD
* \brief Generic in-place singular value decomposition algorithm.
*/
template <typename T>
class PCL_CLASS GenericInPlaceSVD
{
public:
/*!
* Represents a vector involved in a singular value decomposition.
*/
typedef GenericVector<T> vector;
/*!
* Represents a matrix involved in a singular value decomposition.
*/
typedef GenericMatrix<T> matrix;
/*!
* Represents a vector component.
*/
typedef typename vector::component vector_component;
/*!
* Represents a matrix element.
*/
typedef typename matrix::element matrix_element;
/*!
* The components of this vector are the m (positive) diagonal elements of
* the matrix W in a singular value decomposition A=U*W*Vt. m is the number
* of columns in the decomposed matrix A.
*/
vector W;
/*!
* Each column of this m x m matrix is the eigenvector for the corresponding
* element of W in a singular value decomposition A=U*W*Vt. m is the number
* of columns in the decomposed matrix A.
*/
matrix V;
/*!
* Singular Value Decomposition: A = U*W*Vt
*
* The dimensions of A are n rows and m columns. U is an n x m matrix. The m
* components of W are the positive diagonal elements of W, and each column
* of V (m x m) is the eigenvector for the corresponding element of W.
*
* On output, this constructor replaces the specified matrix \a A with the
* matrix U that results from the SVD decomposition (indeed that's why this
* is an in-place decomposition). W and V are stored in the corresponding
* members of this object.
*/
GenericInPlaceSVD( matrix& A )
: W( A.Columns() )
, V( A.Columns(), A.Columns() )
{
InPlaceSVDImplementation( A, W, V );
}
/*!
* Returns the column index of the largest eigenvector in matrix V. This is
* the index of the largest component of vector W.
*/
int IndexOfLargestSingularValue() const
{
return W.IndexOfLargestComponent();
}
/*!
* Returns the column index of the smallest eigenvector in matrix V. This is
* the index of the smallest nonzero component of vector W.
*
* Before calling this function, you should edit the components of vector W
* to set to zero all singular values below a suitable tolerance. For
* example, using the machine epsilon:
*
* \code
* Matrix A;
* ...
* InPlaceSVD svd( A );
* for ( int i = 0; i < svd.W.Length(); ++i )
* if ( 1 + svd.W[i] == 1 )
* svd.W[i] = 0;
* int i = svd.IndexOfSmallestSingularValue();
* ...
* \endcode
*/
int IndexOfSmallestSingularValue() const
{
return W.IndexOfSmallestNonzeroComponent();
}
};
/*!
* \class InPlaceSVD
* \brief In-place singular value decomposition algorithm for Matrix and Vector objects.
*
* %InPlaceSVD is a template instantiation of GenericInPlaceSVD for the double
* type. %InPlaceSVD works with Matrix and Vector objects. %Matrix and %Vector
* are template instantiations of GenericMatrix and GenericVector,
* respectively, for the double type.
*/
class PCL_CLASS InPlaceSVD : public GenericInPlaceSVD<double>
{
public:
/*!
* Identifies the parent template class, which implements the underlying
* algorithm for this class.
*/
typedef GenericInPlaceSVD<double> algorithm_implementation;
/*!
* Represents a vector involved in a singular value decomposition.
*/
typedef algorithm_implementation::vector vector;
/*!
* Represents a matrix involved in a singular value decomposition.
*/
typedef algorithm_implementation::matrix matrix;
/*!
* Represents a vector component.
*/
typedef vector::component vector_component;
/*!
* Represents a matrix element.
*/
typedef matrix::element matrix_element;
/*!
* Singular Value Decomposition: A = U*W*Vt
*
* The dimensions of A are n rows and m columns. U is an n x m matrix. The m
* components of W are the positive diagonal elements of W, and each column
* of V (m x m) is the eigenvector for the corresponding element of W.
*
* On output, this constructor replaces the specified matrix \a A with the
* matrix U that results from the SVD decomposition (indeed that's why this
* is an in-place decomposition). W and V are stored in the corresponding
* members of this object.
*/
InPlaceSVD( matrix& A )
: algorithm_implementation( A )
{
}
};
/*!
* \class FInPlaceSVD
* \brief In-place singular value decomposition algorithm for FMatrix and FVector objects.
*
* %FInPlaceSVD is a template instantiation of GenericInPlaceSVD for the float
* type. %FInPlaceSVD works with FMatrix and FVector objects. %FMatrix and
* %FVector are template instantiations of GenericMatrix and GenericVector,
* respectively, for the float type.
*/
class PCL_CLASS FInPlaceSVD : public GenericInPlaceSVD<float>
{
public:
/*!
* Identifies the parent template class, which implements the underlying
* algorithm for this class.
*/
typedef GenericInPlaceSVD<float> algorithm_implementation;
/*!
* Represents a vector involved in a singular value decomposition.
*/
typedef algorithm_implementation::vector vector;
/*!
* Represents a matrix involved in a singular value decomposition.
*/
typedef algorithm_implementation::matrix matrix;
/*!
* Represents a vector component.
*/
typedef vector::component vector_component;
/*!
* Represents a matrix element.
*/
typedef matrix::element matrix_element;
/*!
* Singular Value Decomposition: A = U*W*Vt
*
* The dimensions of A are n rows and m columns. U is an n x m matrix. The m
* components of W are the positive diagonal elements of W, and each column
* of V (m x m) is the eigenvector for the corresponding element of W.
*
* On output, this constructor replaces the specified matrix \a A with the
* matrix U that results from the SVD decomposition (indeed that's why this
* is an in-place decomposition). W and V are stored in the corresponding
* members of this object.
*/
FInPlaceSVD( matrix& A )
: algorithm_implementation( A )
{
}
};
/*!
* \class GenericSVD
* \brief Generic singular value decomposition algorithm.
*/
template <typename T>
class PCL_CLASS GenericSVD
{
public:
/*!
* Identifies the parent template class, which implements the underlying
* algorithm for this class.
*/
typedef GenericInPlaceSVD<T> algorithm_implementation;
/*!
* Represents a vector involved in a singular value decomposition.
*/
typedef typename algorithm_implementation::vector vector;
/*!
* Represents a matrix involved in a singular value decomposition.
*/
typedef typename algorithm_implementation::matrix matrix;
/*!
* Represents a vector component.
*/
typedef typename vector::component vector_component;
/*!
* Represents a matrix element.
*/
typedef typename matrix::element matrix_element;
/*!
* This is the n x m matrix resulting from the singular value decomposition
* A = U*W*Vt. n and m are the rows and columns of the decomposed matrix A.
*/
matrix U;
/*!
* The components of this vector are the m (positive) diagonal elements of
* the matrix W in a singular value decomposition A = U*W*Vt. m is the
* number of columns in the decomposed matrix A.
*/
vector W;
/*!
* Each column of this m x m matrix is the eigenvector for the corresponding
* element of W in a singular value decomposition A = U*W*Vt. m is the
* number of columns in the decomposed matrix A.
*/
matrix V;
/*!
* Singular Value Decomposition: A = U*W*Vt
*
* The dimensions of A are n rows and m columns. U is an n x m matrix. The m
* components of W are the positive diagonal elements of W, and each column
* of V (m x m) is the eigenvector for the corresponding element of W.
*
* On output, this constructor stores U, W and V in the corresponding
* members of this object.
*/
GenericSVD( const matrix& A )
{
U = A;
algorithm_implementation svd( U );
W = svd.W;
V = svd.V;
}
/*!
* Returns the column index of the largest eigenvector in matrix V. This is
* the index of the largest component of vector W.
*/
int IndexOfLargestSingularValue() const
{
return W.IndexOfLargestComponent();
}
/*!
* Returns the column index of the smallest eigenvector in matrix V. This is
* the index of the smallest nonzero component of vector W.
*
* Before calling this function, you should edit the components of vector W
* to set to zero all singular values below a suitable tolerance. For
* example, using the machine epsilon:
*
* \code
* Matrix A;
* ...
* SVD svd( A );
* for ( int i = 0; i < svd.W.Length(); ++i )
* if ( 1 + svd.W[i] == 1 )
* svd.W[i] = 0;
* int i = svd.IndexOfSmallestSingularValue();
* ...
* \endcode
*/
int IndexOfSmallestSingularValue() const
{
return W.IndexOfSmallestNonzeroComponent();
}
};
/*!
* \class SVD
* \brief Singular value decomposition algorithm for Matrix and Vector objects.
*
* %SVD is a template instantiation of GenericSVD for the double type. %SVD
* works with Matrix and Vector objects. %Matrix and %Vector are template
* instantiations of GenericMatrix and GenericVector, respectively, for the
* double type.
*/
class PCL_CLASS SVD : public GenericSVD<double>
{
public:
/*!
* Identifies the parent template class, which implements the underlying
* algorithm for this class.
*/
typedef GenericSVD<double> algorithm_implementation;
/*!
* Represents a vector involved in a singular value decomposition.
*/
typedef algorithm_implementation::vector vector;
/*!
* Represents a matrix involved in a singular value decomposition.
*/
typedef algorithm_implementation::matrix matrix;
/*!
* Represents a vector component.
*/
typedef vector::component vector_component;
/*!
* Represents a matrix element.
*/
typedef matrix::element matrix_element;
/*!
* Singular Value Decomposition: A = U*W*Vt
*
* The dimensions of A are n rows and m columns. U is an n x m matrix. The m
* components of W are the positive diagonal elements of W, and each column
* of V (m x m) is the eigenvector for the corresponding element of W.
*
* On output, this constructor stores U, W and V in the corresponding
* members of this object.
*/
SVD( const matrix& A )
: algorithm_implementation( A )
{
}
};
/*!
* \class FSVD
* \brief Singular value decomposition algorithm for FMatrix and FVector objects.
*
* %FSVD is a template instantiation of GenericSVD for the float type. %FSVD
* works with FMatrix and FVector objects. %FMatrix and %FVector are template
* instantiations of GenericMatrix and GenericVector, respectively, for the
* float type.
*/
class PCL_CLASS FSVD : public GenericSVD<float>
{
public:
/*!
* Identifies the parent template class, which implements the underlying
* algorithm for this class.
*/
typedef GenericSVD<float> algorithm_implementation;
/*!
* Represents a vector involved in a singular value decomposition.
*/
typedef algorithm_implementation::vector vector;
/*!
* Represents a matrix involved in a singular value decomposition.
*/
typedef algorithm_implementation::matrix matrix;
/*!
* Represents a vector component.
*/
typedef vector::component vector_component;
/*!
* Represents a matrix element.
*/
typedef matrix::element matrix_element;
/*!
* Singular Value Decomposition: A = U*W*Vt
*
* The dimensions of A are n rows and m columns. U is an n x m matrix. The m
* components of W are the positive diagonal elements of W, and each column
* of V (m x m) is the eigenvector for the corresponding element of W.
*
* On output, this constructor stores U, W and V in the corresponding
* members of this object.
*/
FSVD( const matrix& A )
: algorithm_implementation( A )
{
}
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_Algebra_h
// ----------------------------------------------------------------------------
// EOF pcl/Algebra.h - Released 2022-03-12T18:59:29Z
-178
View File
@@ -1,178 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/AlignedAllocator.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_AlignedAllocator_h
#define __PCL_AlignedAllocator_h
/// \file pcl/AlignedAllocator.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/StandardAllocator.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class AlignedAllocator
* \brief A block allocator class for aligned memory allocation/deallocation.
*
* %AlignedAllocator is a <em>block allocator</em> class. It can be used for
* all PCL container classes instead of the default StandardAllocator class,
* from which it derives publicly, providing exactly the same memory allocation
* policies.
*
* %AlignedAllocator guarantees that all allocated memory blocks are aligned
* for optimal performance of SIMD processor instructions on all supported
* platforms. Currently all blocks are allocated with 32 byte alignment, which
* is optimal for both SSE and AVX2 load/store instructions.
*
* For a complete description of block allocators and their fundamental role in
* PCL, read the documentation for the Allocator class.
*
* \sa Allocator, StandardAllocator
*/
class PCL_CLASS AlignedAllocator : public StandardAllocator
{
public:
/*!
* Constructs an %AlignedAllocator object.
*
* \param fastGrowth Whether to enable the fast block size growing policy
* for this allocator.
*
* \param canShrink Whether to enable the block shrinking policy for
* this allocator.
*
* See the IsFastGrowthEnabled() and IsShrinkingEnabled() member functions
* for more information on block allocation policies.
*/
AlignedAllocator( bool fastGrowth = true, bool canShrink = true )
: StandardAllocator( fastGrowth, canShrink )
{
}
/*!
* Copy constructor.
*/
AlignedAllocator( const AlignedAllocator& ) = default;
/*!
* Custom allocation routine. Allocates a contiguous memory block of the
* specified \a size in bytes with 32-byte alignment, and returns the
* address of the first byte in the newly allocated block.
*
* \note This member function is mandatory for a block allocator to be
* usable by the Allocator class.
*
* \sa DeallocateBlock()
*/
void* AllocateBlock( size_type size )
{
PCL_PRECONDITION( size != 0 )
void* p = PCL_ALIGNED_MALLOC( size, 32 );
if ( unlikely( p == nullptr ) )
throw std::bad_alloc();
return PCL_ASSUME_ALIGNED_32( p );
}
/*!
* Custom deallocation routine. Deallocates a previously allocated
* contiguous memory block that begins at the specified location \a p.
*
* \note This member function is mandatory for a block allocator to be
* usable by the Allocator class.
*
* \sa AllocateBlock()
*/
void DeallocateBlock( void* p )
{
PCL_PRECONDITION( p != nullptr )
PCL_ALIGNED_FREE( p );
}
};
} // pcl
// ----------------------------------------------------------------------------
/*!
* Placement new operator for class AlignedAllocator. Returns the specified
* address \a p.
*/
inline void* operator new( pcl::size_type, void* p, pcl::AlignedAllocator& )
{
PCL_PRECONDITION( p != nullptr )
return p;
}
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable: 4100 ) // 'unreferenced formal parameter'
inline void operator delete( void* p, void*, pcl::AlignedAllocator& )
{
PCL_PRECONDITION( p != nullptr )
}
#pragma warning( pop )
#endif // _MSC_VER
// ----------------------------------------------------------------------------
#endif // __PCL_AlignedAllocator_h
// ----------------------------------------------------------------------------
// EOF pcl/AlignedAllocator.h - Released 2022-03-12T18:59:29Z
-409
View File
@@ -1,409 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Allocator.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Allocator_h
#define __PCL_Allocator_h
/// \file pcl/Allocator.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/Relational.h>
#include <pcl/Utility.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class Allocator
* \brief Provides memory allocation for PCL containers.
*
* %Allocator inherits directly from its template argument A, which
* corresponds to a <em>block allocator</em> class. A block allocator is
* responsible for allocation and deallocation of untyped blocks of contiguous
* memory. %Allocator inherits block allocation capabilities and specializes
* them for allocation of a particular type T.
*
* The type T must have default and copy construction semantics.
*
* Besides the default and copy constructors, the block allocator class A must
* define the following member functions:
*
* \code
* size_type A::MaxSize() const
* \endcode
*
* Returns the maximum size in bytes that the block allocator is able to
* allocate as a contiguous memory block.
*
* \code
* size_type A::BlockSize( size_type n ) const
* \endcode
*
* Returns the size in bytes of an <em>allocation block</em> suitable to store
* at least \a n contiguous bytes. %Allocator uses this block size to reserve
* memory in chunks of optimized length. This greatly improves efficiency of
* containers because it minimizes the frequency of allocation/deallocation
* operations.
*
* \code
* size_type A::ReallocatedBlockSize( size_type currentSize, size_type newSize ) const
* \endcode
*
* Returns the size in bytes of a reallocated block. \a currentSize is the
* current size in bytes of the block being reallocated, and \a newSize is the
* requested block size. This function is similar to A::BlockSize(), but it is
* called for reallocation of already existing data blocks, for example before
* deleting a subset of container elements.
*
* \code
* void* AllocateBlock( size_type sz )
* \endcode
*
* Custom allocation routine. Allocates a contiguous memory block of length
* \a sz in bytes, and returns the address of the first byte in the newly
* allocated block.
*
* \code
* void DeallocateBlock( void* p )
* \endcode
*
* Custom deallocation routine. Deallocates a contiguous block of memory that
* has been previously allocated by any allocator of class A.
*
* StandardAllocator is an example of a block allocator that uses the standard
* \c new and \c delete operators.
*
* \sa StandardAllocator
*/
template <class T, class A>
class PCL_CLASS Allocator : public A
{
public:
/*!
* Default constructor.
*/
Allocator() = default;
/*!
* Copy constructor.
*/
Allocator( const Allocator<T,A>& ) = default;
/*!
* Constructs an %Allocator instance as a copy of other block allocator.
*/
Allocator( const A& a )
: A( a )
{
}
/*!
* Allocates a contiguous block of memory, sufficient to store at least \a n
* instance of class T. Optionally, allocates the necessary space for \a n
* objects plus \a extra additional bytes.
*
* Returns the starting address of the allocated block.
*
* \note This member function <em>does not construct</em> any T instance;
* it only allocates the required memory to store \a n instances of T.
*/
T* Allocate( size_type n, size_type extra = 0 )
{
PCL_PRECONDITION( n+extra > 0 )
return (T*)this->AllocateBlock( n*sizeof( T )+extra );
//return (T*)new ( *this ) uint8[ n*sizeof( T )+extra ];
}
/*!
* Deallocates a block of memory.
*
* \note This member function <em>does not destruct</em> any T instance; it
* only deallocates a previously allocated block where an unspecified number
* of T instances might be stored (either constructed or not).
*/
void Deallocate( T* p )
{
PCL_PRECONDITION( p != nullptr )
this->DeallocateBlock( (void*)p );
//this->operator delete( (void*)p );
}
/*!
* Returns the maximum number of instances of class T that this allocator
* can allocate.
*/
size_type MaxLength() const
{
return A::MaxSize()/sizeof( T );
}
/*!
* Returns the length of a newly allocated data block.
*
* Given a number \a n of T instances, returns the corresponding <em>paged
* length</em> for this allocator. The paged length is the actual number of
* T instances that would be allocated instead of \a n, which depends on the
* block allocation policy implemented by the block allocator class.
*
* The value returned by this member function is always greater than or
* equal to \a n.
*
* \sa ShrunkLength()
*/
size_type PagedLength( size_type n ) const
{
return A::BlockSize( n*sizeof( T ) )/sizeof( T );
}
/*!
* Returns the length of a reallocated data block.
*
* \param currentLength The current length of an allocated data block.
*
* \param newLength The new length of the reallocated data block.
*
* The returned length is the actual number of T instances that would be
* allocated instead of \a newLength, which depends on the block allocation
* policy implemented by the block allocator class.
*
* The value returned by this member function is always greater than or
* equal to \a n.
*
* \sa PagedLength()
*/
size_type ReallocatedLength( size_type currentLength, size_type newLength ) const
{
return A::ReallocatedBlockSize( currentLength*sizeof( T ), newLength*sizeof( T ) )/sizeof( T );
}
};
// ----------------------------------------------------------------------------
/*!
* \defgroup object_construction_destruction Construction and&nbsp;\
* Destruction of Objects with Explicit Allocation
*/
/*!
* Constructs an object with storage at address \a p and allocator \a a. This
* function invokes the default constructor of class T for the object stored at
* \a p.
* \sa Allocator
* \ingroup object_construction_destruction
*/
template <class T, class A> inline void Construct( T* p, A& a )
{
PCL_PRECONDITION( p != nullptr )
new( (void*)p, a )T();
}
/*!
* Constructs an object with storage at address \a p, initial value \a v, and
* allocator \a a. This function invokes the copy constructor of class T, with
* argument \a v, for the object stored at \a p.
* \sa Allocator
* \ingroup object_construction_destruction
*/
template <class T, class T1, class A> inline void Construct( T* p, const T1& v, A& a )
{
PCL_PRECONDITION( p != nullptr )
new( (void*)p, a )T( v );
}
#ifdef _MSC_VER
# pragma warning( push )
# pragma warning( disable : 4100 ) // unreferenced formal parameter
#endif // (VC++ limitation !?)
/*!
* Destroys an object stored at address \a p. Invokes the destructor of
* class T for the object stored at \a p.
* \sa Allocator
* \ingroup object_construction_destruction
*/
template <class T> inline void Destroy( T* p )
{
PCL_PRECONDITION( p != nullptr )
p->~T();
}
/*!
* Destroys a contiguous sequence of objects. Invokes the destructor of class
* T for each object in the range [p,q).
* \sa Allocator
* \ingroup object_construction_destruction
*/
template <class T> inline void Destroy( T* p, T* q )
{
PCL_PRECONDITION( p != nullptr && q != nullptr )
for ( ; p < q; ++p )
p->~T();
}
#ifdef _MSC_VER
# pragma warning( pop )
#endif
inline void Destroy( void* ) {}
inline void Destroy( void*, void* ) {}
inline void Destroy( bool* ) {}
inline void Destroy( bool*, bool* ) {}
inline void Destroy( signed char* ) {}
inline void Destroy( signed char*, signed char* ) {}
inline void Destroy( unsigned char* ) {}
inline void Destroy( unsigned char*, unsigned char* ) {}
inline void Destroy( wchar_t* ) {}
inline void Destroy( wchar_t*, wchar_t* ) {}
inline void Destroy( char16_t* ) {}
inline void Destroy( char16_t*, char16_t* ) {}
inline void Destroy( char32_t* ) {}
inline void Destroy( char32_t*, char32_t* ) {}
inline void Destroy( signed int* ) {}
inline void Destroy( signed int*, signed int* ) {}
inline void Destroy( unsigned int* ) {}
inline void Destroy( unsigned int*, unsigned int* ) {}
inline void Destroy( signed short* ) {}
inline void Destroy( signed short*, signed short* ) {}
inline void Destroy( unsigned short* ) {}
inline void Destroy( unsigned short*, unsigned short* ) {}
inline void Destroy( signed long* ) {}
inline void Destroy( signed long*, signed long* ) {}
inline void Destroy( unsigned long* ) {}
inline void Destroy( unsigned long*, unsigned long* ) {}
inline void Destroy( signed long long* ) {}
inline void Destroy( signed long long*, signed long long* ) {}
inline void Destroy( unsigned long long* ) {}
inline void Destroy( unsigned long long*, unsigned long long* ) {}
inline void Destroy( float* ) {}
inline void Destroy( float*, float* ) {}
inline void Destroy( double* ) {}
inline void Destroy( double*, double* ) {}
inline void Destroy( long double* ) {}
inline void Destroy( long double*, long double* ) {}
inline void Destroy( void** ) {}
inline void Destroy( void**, void** ) {}
inline void Destroy( bool** ) {}
inline void Destroy( bool**, bool** ) {}
inline void Destroy( signed char** ) {}
inline void Destroy( signed char**, signed char** ) {}
inline void Destroy( unsigned char** ) {}
inline void Destroy( unsigned char**, unsigned char** ) {}
inline void Destroy( wchar_t** ) {}
inline void Destroy( wchar_t**, wchar_t** ) {}
inline void Destroy( signed int** ) {}
inline void Destroy( signed int**, signed int** ) {}
inline void Destroy( unsigned int** ) {}
inline void Destroy( unsigned int**, unsigned int** ) {}
inline void Destroy( signed short** ) {}
inline void Destroy( signed short**, signed short** ) {}
inline void Destroy( unsigned short** ) {}
inline void Destroy( unsigned short**, unsigned short** ) {}
inline void Destroy( signed long** ) {}
inline void Destroy( signed long**, signed long** ) {}
inline void Destroy( unsigned long** ) {}
inline void Destroy( unsigned long**, unsigned long** ) {}
inline void Destroy( signed long long** ) {}
inline void Destroy( signed long long**, signed long long** ) {}
inline void Destroy( unsigned long long** ) {}
inline void Destroy( unsigned long long**, unsigned long long** ) {}
inline void Destroy( float** ) {}
inline void Destroy( float**, float** ) {}
inline void Destroy( double** ) {}
inline void Destroy( double**, double** ) {}
inline void Destroy( long double** ) {}
inline void Destroy( long double**, long double** ) {}
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_Allocator_h
// ----------------------------------------------------------------------------
// EOF pcl/Allocator.h - Released 2022-03-12T18:59:29Z
-681
View File
@@ -1,681 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Arguments.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Arguments_h
#define __PCL_Arguments_h
/// \file pcl/Arguments.h
#include <pcl/Defs.h>
#include <pcl/Flags.h>
#include <pcl/String.h>
#include <pcl/StringList.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \defgroup argument_parsing Argument Parsing Routines and Utilities
*/
// ----------------------------------------------------------------------------
/*!
* \class Argument
* \brief A command-line argument
*
* %Argument implements a command-line argument that can be used with the
* ParseArguments() function.
*
* Command-line arguments can be \e parametric and \e non-parametric
* arguments (also known as \e item \e arguments).
*
* <b>1. Parametric Arguments</b>
*
* Parametric arguments specify \e modifiers or parameter values of different
* types to their receiving processes. Syntactically, parametric arguments are
* formalized as:
*
* <tt>-&lt;arg_id&gt;[&lt;arg_value&gt;]</tt>
*
* where the starting hypen character '-' is the <em>standard parameter
* prefix.</em> &lt;arg_id&gt; is the <em>argument identifier</em> and
* &lt;arg_value&gt; is an optional <em>argument value</em> specification. For
* example, in the following parametric arguments:
*
* <tt>-n=17 --use-all-processors</tt>
*
* the argument identifiers are 'n' and '-use-all-processors', respectively,
* and '=17' is an argument value specification.
*
* We consider four types of parametric arguments: \e literal, \e switch,
* \e numeric and \e string arguments.
*
* <b>1.1 Literal Arguments</b>
*
* Literal arguments are parametric arguments that don't have a particular
* value. They are modifiers that act as functions of their existence. For
* example, in the following arguments:
*
* <tt>-c -x=10 -b="none" --verbose</tt>
*
* '-c' and '--verbose' are literal arguments.
*
* <b>1.2 Switch Arguments</b>
*
* Switch arguments are parametric arguments that can only have a boolean
* \e enabled/disabled state. Switch arguments are of the form:
*
* <tt>-&lt;arg_id&gt;+|-</tt>
*
* where the + suffix means 'enabled' and the - suffix means 'disabled'.
* For example, here are some switch arguments:
*
* <tt>-u+ -color- --mySwitchArgument+</tt>
*
* It is customary to allow the use of switch arguments also as literal
* arguments. When switch arguments are used as literal arguments, a default
* 'enabled' or 'disabled' state is assumed, depending on the functionality and
* purpose of each argument. When switch arguments can also be literal, they
* are formalized as:
*
* <tt>-&lt;arg_id&gt;[+|-]</tt>
*
* indicating that the + and - suffixes are optional.
*
* <b>1.3 Numeric Arguments</b>
*
* A numeric argument has an integer or floating-point numeric value. Numeric
* arguments are formalized as:
*
* <tt>-&lt;arg_id&gt;=&lt;numeric_constant&gt;</tt>
*
* where &lt;numeric_constant&gt; is a valid representation of an integer or
* floating-point real constant, following the applicable syntax rules of the C
* language. Integer constants can have the '0x' standard prefix to indicate
* hexadecimal values.
*
* <b>1.4 %String Arguments</b>
*
* A string argument has a literal value represented as a string of ISO 8859-1
* characters. String arguments are formalized as:
*
* <tt>-&lt;arg_id&gt;=&lt;string_constant&gt;</tt>
*
* where &lt;string_constant&gt; is any sequence of ISO 8859-1 characters,
* optionally enclosed by double quotes. For example:
*
* <tt>-s=foo -s1="bar"</tt>
*
* are two string arguments with 'foo' and 'bar' values, respectively. When the
* &lt;string_constant&gt; string includes white spaces, the enclosing quotes are
* not optional, as in:
*
* <tt>-aStringArg="this is a string literal"</tt>
*
* or otherwise the above sequence would be interpreted as a single string
* argument (aStringArg=this) and four additional, non-parametric arguments.
*
* <b>2. Non-Parametric Arguments</b>
*
* Non-parametric arguments specify \e objects that their receiving processes
* can act on or use in any way. Non-parametric arguments are formalized as:
*
* <tt>&lt;arg_value&gt;</tt>
*
* where &lt;arg_value&gt; is any sequence of ISO 8859-1 characters. Note that the
* absence of a <em>standard parameter prefix</em> (the hypen character, '-')
* characterizes non-parametric arguments. For example, in the following
* arguments:
*
* <tt>-mode="auto" *.js -z foo.scp</tt>
*
* '*.js' and 'foo.scp' are two non-parametric arguments.
*
* Each non-parametric argument can be expanded into a <em>list of items.</em>
* For example, the '*.js' argument above would be expanded into a list of all
* files with the .js suffix in the current directory, provided that the
* argument is parsed as a wild file path specification.
*
* \sa ParseArguments(), ArgumentItemMode, ArgumentOption
*
* \ingroup argument_parsing
*/
class PCL_CLASS Argument
{
public:
/*!
* Constructs an empty %Argument object.
*/
Argument()
{
Initialize();
}
/*!
* Constructs an %Argument object and parses the specified \a argv string.
*/
Argument( const String& argv )
{
Parse( argv.c_str() );
}
/*!
* Constructs an %Argument object and parses the specified \a argv string.
*/
Argument( const char16_type* argv )
{
Parse( argv );
}
/*!
* Constructs an %Argument object and interprets that the specified \a argv
* string corresponds to a non-parametric argument corresponding to the
* \a items list of items.
*/
Argument( const String& argv, const StringList& items )
{
type = item_arg;
token = argv;
asItems = items;
}
/*!
* Copy constructor.
*/
Argument( const Argument& ) = default;
/*!
* Copy assignment operator. Returns a reference to this object.
*/
Argument& operator =( const Argument& ) = default;
/*!
* Equality operator. Returns true if this %Argument object is equal to the
* specified \a x instance.
*/
bool operator ==( const Argument& x ) const
{
if ( id == x.id && type == x.type )
{
if ( IsLiteral() || !IsValid() )
return true;
if ( IsNumeric() )
return asNumeric == x.asNumeric;
if ( IsString() )
return asString == x.asString;
if ( IsSwitch() )
return asSwitch == x.asSwitch;
if ( IsItemList() )
return asItems == x.asItems;
}
return false;
}
/*!
* Returns true iff this argument has successfully parsed a token string.
*/
bool IsValid() const
{
return type != invalid_arg;
}
/*!
* Returns the token string corresponding to this argument. The token is the
* exact string that has been parsed by this %Argument instance. If no token
* has been parsed by this instance, an empty string is returned.
*/
String Token() const
{
return token;
}
/*!
* Returns the argument's parameter identifier, if this argument has been
* parsed and it is a <em>parametric argument</em>, or an empty string
* otherwise.
*/
String Id() const
{
return id;
}
/*!
* Returns true iff this argument has been parsed and it is a
* <em>non-parametric argument</em>, also known as an <em>item
* argument.</em>
*/
bool IsItemList() const
{
return type == item_arg;
}
/*!
* Returns a reference to the (constant) list of items that have been
* generated after expansion of a non-parametric argument. The returned list
* cannot be modified, and it's empty if this argument is parametric, or if
* it has not been parsed yet.
*/
const StringList& Items() const
{
return asItems;
}
/*!
* Returns a reference to the list of items that have been generated after
* expansion of a non-parametric argument. The returned list can be freely
* modified, and it's empty if this argument is parametric, or if it has not
* been parsed yet.
*/
StringList& Items()
{
return asItems;
}
/*!
* Returns true iff this argument has been parsed and it is a <em>literal
* argument</em>.
*/
bool IsLiteral() const
{
return type == literal_arg;
}
/*!
* Returns true iff this argument has been parsed and it is a <em>switch
* argument</em>.
*/
bool IsSwitch() const
{
return type == switch_arg;
}
/*!
* Returns the switch state of this argument, if it has been parsed and it
* is a <em>switch argument</em>, or false otherwise.
*/
bool SwitchState() const
{
return asSwitch;
}
/*!
* Returns true iff this argument has been parsed and it is a <em>numeric
* argument</em>.
*/
bool IsNumeric() const
{
return type == numeric_arg;
}
/*!
* Returns the numeric value of this argument, if it has been parsed and it
* is a <em>numeric argument</em>, or zero otherwise.
*/
double NumericValue() const
{
return asNumeric;
}
/*!
* Returns true iff this argument has been parsed and it is a <em>string
* argument</em>.
*/
bool IsString() const
{
return type == string_arg;
}
/*!
* Returns the string value of this argument, if it has been parsed and it
* is a <em>string argument</em>, or an empty string otherwise.
*/
String StringValue() const
{
return asString;
}
private:
enum arg_type { invalid_arg = -1, item_arg, literal_arg, switch_arg, numeric_arg, string_arg };
String token; // argument token
String id; // argument id
arg_type type; // argument type, or invalid
StringList asItems; // list of non-parameters (e.g. file names or view ids)
bool asSwitch; // logical state of a switch argument
double asNumeric; // value of a numerical argument
String asString; // value of a string argument
void Initialize()
{
token.Clear();
id.Clear();
type = invalid_arg;
asItems.Clear();
asSwitch = false;
asNumeric = 0;
asString.Clear();
}
void Parse( const char16_type* );
};
/*!
* \class pcl::ArgumentList
* \brief A dynamic array of command-line arguments
* \ingroup argument_parsing
*/
typedef Array<Argument> ArgumentList;
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::ArgumentItemMode
* \brief Non-parametric argument parsing modes.
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>ArgumentItemMode::Ignore</td> <td>Consider non-parametric items as literal items (plain strings)</td></tr>
* <tr><td>ArgumentItemMode::AsFiles</td> <td>Non-parametric items are file paths</td></tr>
* <tr><td>ArgumentItemMode::AsViews</td> <td>Non-parametric items are view identifiers</td></tr>
* <tr><td>ArgumentItemMode::NoItems</td> <td>Non-parametric items are not allowed</td></tr>
* </table>
*
* \ingroup argument_parsing
*/
namespace ArgumentItemMode
{
enum value_type
{
Ignore, // Consider non-parametric items as literal items (plain strings)
AsFiles, // Non-parametric items are file paths
AsViews, // Non-parametric items are view identifiers
NoItems, // Non-parametric items are not allowed
};
}
/*!
* \class pcl::argument_item_mode
* \brief Represents an ArgumentItemMode enumerated value.
* \ingroup argument_parsing
*/
typedef ArgumentItemMode::value_type argument_item_mode;
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::ArgumentOption
* \brief Working options affecting how non-parametric arguments are
* interpreted.
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>ArgumentOption::AllowWildcards</td> <td>Allow wildcard characters (*?) in non-parametric items</td></tr>
* <tr><td>ArgumentOption::NoPreviews</td> <td>Don't allow preview specifications (with the '->' standard separator)</td></tr>
* <tr><td>ArgumentOption::RecursiveDirSearch</td> <td>Perform recursive directory searches for wild path specifications</td></tr>
* <tr><td>ArgumentOption::RecursiveSearchArgs</td> <td>Use standard arguments to toggle recursive directory searching</td></tr>
* </table>
*
* \ingroup argument_parsing
*/
namespace ArgumentOption
{
enum mask_type
{
AllowWildcards = 0x00000001, // Allow wildcard characters (*?) in non-parametric items
NoPreviews = 0x00000002, // Don't allow preview specifications (with the '->' standard separator)
RecursiveDirSearch = 0x00000004, // Perform recursive directory searches for wild path specifications
RecursiveSearchArgs = 0x00000008, // Use standard arguments to toggle recursive directory searching
};
}
/*!
* \class pcl::ArgumentOptions
* \brief A combination of ArgumentOption flags
* \ingroup argument_parsing
*/
typedef Flags<ArgumentOption::mask_type> ArgumentOptions;
// ----------------------------------------------------------------------------
// The implementation of ExtractArguments() is slightly different in core.
#ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
} // pcl
using namespace pcl;
namespace pi
{
#endif
/*!
* Extracts a sequence of command-line arguments of the form:
*
* <tt>[&lt;arg_list&gt;] [&lt;item_list&gt;]</tt>
*
* where:
*
* <tt>&lt;item_list&gt;</tt>
* Is a sequence <tt>&lt;item&gt; [&lt;item_list&gt;]</tt>
*
* <tt>&lt;item&gt;</tt>
* Is a non-parametric (or "item") argument. If <em>file parsing</em> is active
* (see the \a mode parameter below), each item will be parsed as a file path
* specification. If <em>view parsing</em> is active, items will be considered
* as view identifiers. In both cases, each item may include wildcards to
* define a search pattern, which will be automatically expanded into a
* sequence of actual file paths or view identifiers.
*
* <tt>&lt;arg_list&gt;</tt>
* Is a sequence <tt>&lt;arg&gt; [&lt;arg_list&gt;]</tt>
*
* <tt>&lt;arg&gt;</tt>
* Is a parametric argument (see the documentation for the Argument class for a
* complete description).
*
* \param argv The list of input argument tokens that will be parsed.\n\n
*
* \param mode Indicates how non-parametric items will be handled by this
* function. \a mode must have one of the following values:\n
* \n
* <table border="1" cellpadding="4" cellspacing="0">
* <tr>
* <td><b>ArgumentItemMode::Ignore</b>. Non-parametric arguments will
* not be parsed and will be passed unchanged.</td></tr>
* <tr>
* <td><b>ArgumentItemMode::AsFiles</b>. Each non-parametric argument
* is interpreted as a file path specification. Note that neither
* validity of file paths nor the existence of actual files are
* verified.</td></tr>
* <tr>
* <td><b>ArgumentItemMode::AsViews</b>. Each non-parametric argument
* is interpreted and parsed as a view identifier specification. Note
* that only validity of view identifiers is verified, not the
* existence of actual views with such identifiers.</td></tr>
* <tr>
* <td><b>ArgumentItemMode::NoItems</b>. This mode disallows
* non-parametric arguments. An exception is thrown if a
* non-parametric item is found in the input sequence of \a argv
* elements.</td></tr>
* </table>\n\n
*
* \param options This is an OR'ed combination of flags from the
* ArgumentOption enumeration:\n
* \n
* <table border="1" cellpadding="4" cellspacing="0">
* <tr>
* <td><b>ArgumentItemMode::AllowWildcards</b>. If this flag is
* included, each file argument containing wildcards ('*' and '?'
* characters) will originate a search for all files matching the
* specified wildcard pattern. If view arguments are being considered,
* each wildcard item will be expanded into a list of matching view
* identifiers.</td></tr>
* <tr>
* <td><b>ArgumentItemMode::NoPreviews</b>. This flag prevents the
* inclusion of preview identifiers in the output arguments set. If a
* preview specification (imageId->previewId) is found and this flag
* is active, an exception is thrown.</td></tr>
* <tr>
* <td><b>ArgumentItemMode::RecursiveDirSearch</b>. This flag only
* makes sense along with the ArgumentItemMode::AsFiles mode. If used,
* this flag will originate recursive directory searches for all file
* path specifications containing wildcards. Note that the behavior of
* this flag can be altered by the RecursiveSearchArgs flag (see
* below).</td></tr>
* <tr>
* <td><b>ArgumentItemMode::RecursiveSearchArgs</b>. This flag only
* makes sense along with the ArgumentItemMode::AsFiles mode and the
* RecursiveDirSearch flag (see above). If used, recursive directory
* searches will be controlled by a special toggle argument. All
* instances of this argument will be processed automatically by the
* routine and will not be included in the output arguments list. By
* default, this argument is <tt>--r[+|-]</tt>, but it can be changed
* by calling the SetRecursiveDirSearchArgument() static function.\n
* \n
* Example of wild path argument specifications with recursive search
* through the standard <tt>--r</tt> toggle argument:
*
* <tt>*.cpp --r *.h *.png --r- *.exe</tt>
*
* In the example above, <tt>*.h</tt> and <tt>*.png</tt> will be
* searched recursively through the entire directory tree rooted at
* the current directory, but <tt>*.cpp</tt> and <tt>*.exe</tt> files
* will only be searched for in the current directory.</td></tr>
* </table>
*
* This function generates a ParseError exception when it encounters an error
* while parsing the sequence of input arguments.
*
* Returns a list with all the arguments extracted from the input \a argv
* sequence as instances of the Argument class. If non-parametric arguments are
* being interpreted as file paths, each non-parametric item is expanded to its
* corresponding full file path. If non-parametric arguments are being parsed
* as view identifiers, each non-parametric item is replaced (if appropriate)
* by its full view identifier. Otherwise, non-parametric items are returned
* unchanged.
*
* \ingroup argument_parsing
*/
ArgumentList PCL_FUNC ExtractArguments( const StringList& argv,
argument_item_mode mode = ArgumentItemMode::Ignore,
ArgumentOptions options = ArgumentOptions() );
#ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
} // pi
namespace pcl
{
#endif
/*!
* Returns the identifier of the argument used by ExtractArguments() for
* automatic toggle of recursive directory searches. By default, this is the
* <tt>--r[+|-]</tt> argument.
*
* \ingroup argument_parsing
*/
String PCL_FUNC RecursiveDirSearchArgument();
/*!
* Sets the identifier of the argument used by ExtractArguments() for
* automatic toggle of recursive directory searches.
*
* \param id New identifier for the automatic recursive search argument.
* N.B.: When specifying this argument, don't include the '-'
* standard parameter prefix.
*
* \ingroup argument_parsing
*/
void PCL_FUNC SetRecursiveDirSearchArgument( const String& id );
/*!
* Auxiliary directory search routine used by ExtractArguments().
*
* Returns a list of full file paths corresponding to a template wild file
* specification (\a filePath), optionally recursing the directory tree,
* starting from the directory specified in \a filePath.
*
* \ingroup argument_parsing
*/
StringList PCL_FUNC SearchDirectory( const String& filePath, bool recursive = false );
/*!
* Returns a copy of a source string \a s where all references to environment
* variables have been replaced with their corresponding values.
*
* This function finds all occurrences of environment variables of the form:
*
* $&lt;env_name&gt;
*
* where &lt;env_name&gt; is any sequence of alphabetic, decimal, or underscore
* characters. If &lt;env_name&gt; corresponds to an existing environment
* variable of the calling process, the entire $&lt;env_name&gt; sequence is
* replaced with the variable's value. References to nonexistent environment
* variables, as well as empty references (isolated $ characters), are
* replaced with an empty string (removed).
*
* This function works recursively: it can replace environment variables
* inside the values of environment variables. The routine performs
* replacements recursively until no $ character is found in the string.
*
* \ingroup argument_parsing
*/
String PCL_FUNC ReplaceEnvironmentVariables( const String& s );
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_Arguments_h
// ----------------------------------------------------------------------------
// EOF pcl/Arguments.h - Released 2022-03-12T18:59:29Z
-2171
View File
File diff suppressed because it is too large Load Diff
-164
View File
@@ -1,164 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Association.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Association_h
#define __PCL_Association_h
/// \file pcl/Association.h
#include <pcl/Defs.h>
#include <pcl/Relational.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class Association
* \brief Generic association of two objects.
*/
template <typename T1, typename T2>
class PCL_CLASS Association
{
public:
T1 first; //!< First member of this association
T2 second; //!< Second member of this association
/*!
* Constructs an association with default-constructed member values.
*/
Association() = default;
/*!
* Copy constructor.
*/
Association( const Association<T1,T2>& ) = default;
/*!
* Move constructor.
*/
Association( Association<T1,T2>&& ) = default;
/*!
* Constructs an association with the specified values \a x1 and \a x2,
* respectively for the \a first and \a second members.
*/
Association( const T1& x1, const T2& x2 )
: first( x1 )
, second( x2 )
{
}
};
// ----------------------------------------------------------------------------
/*!
* \defgroup association_utilities Association Operators and Utility Functions
*/
/*!
* Returns an Association whose members are copies of the specified objects
* \a x1 and \a x2.
* \ingroup association_utilities
*/
template <typename T1, typename T2> inline
Association<T1,T2> Associate( const T1& x1, const T2& x2 )
{
return Association<T1,T2>( x1, x2 );
}
/*!
* Returns true iff two associations, \a x1 and \a x2, are equal. Two
* associations are equal if their homolog members are equal.
* \ingroup association_utilities
*/
template <typename T1, typename T2> inline
bool operator ==( const Association<T1,T2>& x1, const Association<T1,T2>& x2 )
{
return x1.first == x2.first && x1.second == x2.second;
}
/*!
* Returns true iff an association \a x1 is less than other association \a x2.
* The comparison algorithm is as follows:
*
* \code
* if ( x1.first == x2.first )
* return x1.second < x2.second;
* else
* return x1.first < x2.first;
* \endcode
*
* So in association comparisons the first member of each association has
* precedence over the second member.
*
* The implementation of this operator only requires <em>less than</em>
* semantics for the two types T1 and T2; it doesn't use equality operators.
* \ingroup association_utilities
*/
template <typename T1, typename T2> inline
bool operator <( const Association<T1,T2>& x1, const Association<T1,T2>& x2 )
{
//return (x1.first == x2.first) ? x1.second < x2.second : x1.first < x2.first;
return (x1.first < x2.first) ? true : ((x2.first < x1.first) ? false : x1.second < x2.second);
}
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_Association_h
// ----------------------------------------------------------------------------
// EOF pcl/Association.h - Released 2022-03-12T18:59:29Z
File diff suppressed because it is too large Load Diff
-670
View File
@@ -1,670 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Atomic.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Atomic_h
#define __PCL_Atomic_h
/// \file pcl/Atomic.h
#include <pcl/Defs.h>
#ifdef __PCL_WINDOWS
# include <intrin.h>
#ifdef _MSC_VER
# pragma intrinsic (_InterlockedIncrement)
# pragma intrinsic (_InterlockedDecrement)
# pragma intrinsic (_InterlockedCompareExchange)
# pragma intrinsic (_InterlockedExchange)
# pragma intrinsic (_InterlockedExchangeAdd)
#endif
#endif
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class AtomicInt
* \brief Atomic operations on integers.
*
* %AtomicInt allows non-blocking synchronization of multithreaded code with
* respect to reference counting and other critical operations in parallel
* algorithm implementations. This class is used extensively by PCL code to
* implement copy-on-write shared containers and container operations in a
* thread-safe way. An example is the ReferenceCounter class, which is at the
* hearth of most PCL container and image classes.
*
* %AtomicInt implements the following synchronization primitives on integers:
*
* reference \n
* dereference \n
* test-and-set \n
* fetch-and-store \n
* fetch-and-add
*
* \sa ReferenceCounter
*/
class PCL_CLASS AtomicInt
{
public:
/*!
* Constructs an %AtomicInt instance with the specified \a value. When not
* explicitly specified, the default value is zero.
*/
AtomicInt( int value = 0 )
: m_value( value )
{
// ### N.B.:
// The default zero initialization is *critical* - DO NOT change it.
}
/*!
* Copy constructor.
*/
AtomicInt( const AtomicInt& ) = default;
/*!
* Copy assignment operator. Returns a reference to this object.
*/
AtomicInt& operator =( const AtomicInt& ) = default;
/*!
* Returns the current value of this atomic integer.
*
* \note This operation is not guaranteed to be atomic.
*/
operator int() const
{
return m_value;
}
/*!
* Logical negation operator. Returns true iff this atomic integer is zero.
*
* \note This operation is not guaranteed to be atomic.
*/
bool operator !() const
{
return m_value == 0;
}
/*!
* Equality operator. Returns true iff this atomic integer is equal to an
* integer \a x.
*
* \note This operation is not guaranteed to be atomic.
*/
bool operator ==( int x ) const
{
return m_value == x;
}
/*!
* Inequality operator. Returns true iff this atomic integer is not equal to
* an integer \a x.
*
* \note This operation is not guaranteed to be atomic.
*/
bool operator !=( int x ) const
{
return m_value != x;
}
/*!
* Integer assignment operator. Assigns the specified integer \a x to this
* atomic integer. Returns a reference to this object.
*
* \note This operation is not guaranteed to be atomic.
*/
AtomicInt& operator =( int x )
{
m_value = x;
return *this;
}
/*!
* Atomic load operation.
*
* Returns the current value of this atomic integer.
*
* \note The integer load operation is guaranteed to be atomic on all
* supported platforms and architectures.
*/
int Load()
{
return FetchAndAdd( 0 );
}
/*!
* Atomic store operation.
*
* Assigns the specified \a newValue to this object.
*
* \note The integer store operation is guaranteed to be atomic on all
* supported platforms and architectures.
*/
void Store( int newValue )
{
(void)FetchAndStore( newValue );
}
/*!
* Atomic increment operation.
*
* Increments the value of this object as an atomic operation.
*
* \note This operation is guaranteed to be atomic on all supported
* platforms and architectures.
*/
void Increment()
{
#ifdef __PCL_WINDOWS
(void)_InterlockedIncrement( &m_value );
#else
asm volatile( "lock\n\t"
"incl %0\n"
: "=m" (m_value)
: "m" (m_value)
: "memory", "cc" );
#endif
}
/*!
* Atomic decrement operation.
*
* Decrements the value of this object as an atomic operation.
*
* \note This operation is guaranteed to be atomic on all supported
* platforms and architectures.
*/
void Decrement()
{
#ifdef __PCL_WINDOWS
(void)_InterlockedDecrement( &m_value );
#else
asm volatile( "lock\n\t"
"decl %0\n"
: "=m" (m_value)
: "m" (m_value)
: "memory", "cc" );
#endif
}
/*!
* Atomic reference operation.
*
* Increments the value of this object as an atomic operation. Returns true
* if the resulting value after incrementing this object is nonzero.
*
* \note This operation is guaranteed to be atomic on all supported
* platforms and architectures.
*/
bool Reference()
{
#ifdef __PCL_WINDOWS
return _InterlockedIncrement( &m_value ) != 0;
#else
uint8 result;
asm volatile( "lock\n\t"
"incl %0\n\t"
"setnz %1\n"
: "=m" (m_value), "=qm" (result)
: "m" (m_value)
: "memory", "cc" );
return result != 0;
#endif
}
/*!
* Atomic dereference operation.
*
* Decrements the value of this object as an atomic operation. Returns true
* if the resulting value after decrementing this object is nonzero.
*
* \note This operation is guaranteed to be atomic on all supported
* platforms and architectures.
*/
bool Dereference()
{
#ifdef __PCL_WINDOWS
return _InterlockedDecrement( &m_value ) != 0;
#else
uint8 result;
asm volatile( "lock\n\t"
"decl %0\n\t"
"setnz %1\n"
: "=m" (m_value), "=qm" (result)
: "m" (m_value)
: "memory", "cc" );
return result != 0;
#endif
}
/*!
* Atomic test-and-set operation.
*
* If the current value of this object is equal to \a expectedValue, this
* function assigns \a newValue to this object and returns true. If the
* current value is not equal to \a expectedValue, this function performs no
* operation and returns false.
*
* \note This operation is guaranteed to be atomic on all supported
* platforms and architectures.
*/
bool TestAndSet( int expectedValue, int newValue )
{
#ifdef __PCL_WINDOWS
return _InterlockedCompareExchange( &m_value, newValue, expectedValue ) == expectedValue;
#else
uint8 result;
asm volatile( "lock\n\t"
"cmpxchgl %3,%2\n\t"
"setz %1\n"
: "=a" (newValue), "=qm" (result), "+m" (m_value)
: "r" (newValue), "0" (expectedValue)
: "memory", "cc" );
return result != 0;
#endif
}
/*!
* Atomic fetch-and-store operation.
*
* Assigns \a newValue to this object and returns the initial value before
* assignment, as an atomic operation.
*
* \note This operation is guaranteed to be atomic on all supported
* platforms and architectures.
*/
int FetchAndStore( int newValue )
{
#ifdef __PCL_WINDOWS
return _InterlockedExchange( &m_value, newValue );
#else
asm volatile( "xchgl %0,%1\n"
: "=r" (newValue), "+m" (m_value)
: "0" (newValue)
: "memory" );
return newValue;
#endif
}
/*!
* Atomic fetch-and-add operation. Adds \a valueToAdd to this object and
* returns the initial value before addition, as an atomic operation.
*
* \note This operation is guaranteed to be atomic on all supported
* platforms and architectures.
*/
int FetchAndAdd( int valueToAdd )
{
#ifdef __PCL_WINDOWS
return _InterlockedExchangeAdd( &m_value, valueToAdd );
#else
asm volatile( "lock\n\t"
"xaddl %0,%1\n"
: "=r" (valueToAdd), "+m" (m_value)
: "0" (valueToAdd)
: "memory", "cc" );
return valueToAdd;
#endif
}
private:
#ifdef _MSC_VER
__declspec(align(4)) volatile long m_value;
#elif __PCL_WINDOWS
volatile long m_value __attribute__ ((aligned (4)));
#else
volatile int m_value __attribute__ ((aligned (4)));
#endif
};
// ----------------------------------------------------------------------------
/*!
* \defgroup reentrancy_protection Thread-Safe Protection of Non-Reentrant Code
*/
// ----------------------------------------------------------------------------
/*!
* \class AutoReentrancyGuard
* \brief Automatic reentrancy guard sentinel.
*
* %AutoReentrancyGuard allows you to protect a block of code ensuring that it
* cannot be reentrant. All you need is a static AtomicInt variable that works
* as a 'busy state' flag persistent across function invocations.
*
* Consider the following example:
*
* \code void foo()
* {
* static AtomicInt flag;
* AutoReentrancyGuard guard( flag );
* if ( guard )
* {
* // protected code
* }
* }
* \endcode
*
* The function \c foo is not reentrant, so we want to protect it against
* possible reentrant invocations while the function's code is being executed.
*
* The \c flag variable is initially zero (because AtomicInt's default
* constructor initializes its integer member to zero). The first time \c foo
* is called, %AutoReentrancyGuard's constructor can change the value of
* \c flag from zero to one as an atomic operation. When this happens,
* AutoReentrancyGuard::operator bool() returns true, and the code protected
* within the \c if block can be executed.
*
* When the \c guard object gets out of scope (just before the \c foo function
* returns), its class destructor resets \c flag to zero automatically, which
* permits the next non-reentrant execution of \c foo. However, if \c foo is
* called again before \c guard is destroyed, a newly constructed
* %AutoReentrancyGuard object cannot make a transition 0 -> 1 with the static
* \c flag variable, and hence a reentrant execution of the protected code is
* not allowed (in this case, the function simply does nothing and returns
* after the \c if block). Note that the protected code can freely return from
* the function or throw exceptions; the \c flag variable will be reset to zero
* automatically when \c guard gets out of scope.
*
* Since %AutoReentrancyGuard uses AtomicInt to implement atomic transitions,
* code blocks can be protected against reentrant execution in multithreaded
* environments.
*
* The macros PCL_REENTRANCY_GUARDED_BEGIN and PCL_REENTRANCY_GUARDED_END
* greatly simplify reentrancy protection. For example, the above code could be
* implemented as follows:
*
* \code void foo()
* {
* PCL_REENTRANCY_GUARDED_BEGIN
* // protected code
* PCL_REENTRANCY_GUARDED_END
* } \endcode
*
* In addition, the macros PCL_CLASS_REENTRANCY_GUARD and
* PCL_CLASS_REENTRANCY_GUARDED_BEGIN are useful for protection of all
* non-reentrant member functions of a class, and the macros
* PCL_MEMBER_REENTRANCY_GUARD and PCL_MEMBER_REENTRANCY_GUARDED_BEGIN provide
* protection of specific member functions. See these macros for examples.
*
* \ingroup reentrancy_protection
*/
class AutoReentrancyGuard
{
public:
/*!
* Constructs an %AutoReentrancyGuard object to monitor the specified
* \a guard variable. If \c guard is zero, its value is set to one as an
* atomic operation. If \c guard is nonzero, its value is not changed.
*
* \warning The monitored guard variable *must* be either a static variable
* local to the function being protected, or a data member of the same class
* to which a protected member function belongs. Otherwise the protection
* mechanism will not work. This can be dangerous, especially because you
* may erroneously think that your code is being protected when it is not.
* In addition, the guard variable must be zero initially, or the protected
* code will never be allowed to work. We strongly recommend you don't use
* this class directly, but the PCL_REENTRANCY_GUARDED_BEGIN and
* PCL_REENTRANCY_GUARDED_END macros to implement function level protection,
* or PCL_CLASS_REENTRANCY_GUARD, PCL_CLASS_REENTRANCY_GUARDED_BEGIN and
* PCL_CLASS_REENTRANCY_GUARDED_END to implement per-instance function
* member protection.
*/
AutoReentrancyGuard( AtomicInt& guard )
: m_guard( guard )
{
m_guarded = m_guard.TestAndSet( 0, 1 );
}
/*!
* Destroys this object. If the value of the monitored guard variable (see
* the class constructor) was zero when this object was constructed, its
* value is reset to zero as an atomic operation.
*/
~AutoReentrancyGuard()
{
if ( m_guarded )
m_guard.Store( 0 );
}
/*!
* Returns true iff the value of the monitored guard variable (see the class
* constructor) was zero when this object was constructed.
*/
operator bool() const volatile
{
return m_guarded;
}
private:
AtomicInt& m_guard;
bool m_guarded = false;
};
/*!
* \def PCL_REENTRANCY_GUARDED_BEGIN
*
* This macro along with PCL_REENTRANCY_GUARDED_END simplifies protection of
* non-reentrant code. See the AutoReentrancyGuard class for detailed
* information and examples.
*
* \ingroup reentrancy_protection
*/
#define PCL_REENTRANCY_GUARDED_BEGIN \
{ \
static pcl::AtomicInt __r_g__( 0 ); \
volatile pcl::AutoReentrancyGuard __a_r_g__( __r_g__ ); \
if ( __a_r_g__ ) \
{
/*!
* \def PCL_REENTRANCY_GUARDED_END
*
* This macro, along with PCL_REENTRANCY_GUARDED_BEGIN, simplifies protection
* of non-reentrant code. See the AutoReentrancyGuard class for detailed
* information and examples.
*
* \ingroup reentrancy_protection
*/
#define PCL_REENTRANCY_GUARDED_END \
} \
}
/*!
* \def PCL_CLASS_REENTRANCY_GUARD
*
* Declares a class data member for class-wide protection of non-reentrant
* member functions with the PCL_CLASS_REENTRANCY_GUARDED_BEGIN and
* PCL_REENTRANCY_GUARDED_END macros.
*
* Example:
*
* \code class foo
* {
* public:
* // ...
* private:
* PCL_CLASS_REENTRANCY_GUARD
*
* void bar1()
* {
* PCL_CLASS_REENTRANCY_GUARDED_BEGIN
* // Protected code
* PCL_REENTRANCY_GUARDED_END
* }
*
* void bar2() const
* {
* PCL_CLASS_REENTRANCY_GUARDED_BEGIN
* // Protected code
* PCL_REENTRANCY_GUARDED_END
* }
* }; \endcode
*
* In this example the bar1 and bar2 member functions are protected against
* reentrant execution. Note that reentrancy protection is a per-instance,
* class-wide property in this case: the bar1() and bar2() functions can be
* executed simultaneously for different objects, but they cannot be re-entered
* for the same instance. Furthermore, one of these functions cannot call the
* other for the same object, since both share the same reentrancy guard member
* in the foo class.
*
* See the AutoReentrancyGuard class for more information on the PCL
* implementation of reentrancy protection.
*
* \ingroup reentrancy_protection
*/
#define PCL_CLASS_REENTRANCY_GUARD \
mutable pcl::AtomicInt __pcl_guard__;
/*!
* \def PCL_CLASS_REENTRANCY_GUARDED_BEGIN
*
* This macro, along with PCL_CLASS_REENTRANCY_GUARD and
* PCL_REENTRANCY_GUARDED_END, simplifies per-instance protection of
* non-reentrant class member functions. See PCL_CLASS_REENTRANCY_GUARD for an
* example.
*
* See the AutoReentrancyGuard class for more information on the PCL
* implementation of reentrancy protection.
*
* \ingroup reentrancy_protection
*/
#define PCL_CLASS_REENTRANCY_GUARDED_BEGIN \
{ \
volatile pcl::AutoReentrancyGuard __a_r_g__( __pcl_guard__ ); \
if ( __a_r_g__ ) \
{
/*!
* \def PCL_MEMBER_REENTRANCY_GUARD
*
* Declares a class data member for protection of a specific non-reentrant
* member function with the PCL_MEMBER_REENTRANCY_GUARDED_BEGIN and
* PCL_REENTRANCY_GUARDED_END macros.
*
* Example:
*
* \code class foo
* {
* public:
* // ...
* private:
* PCL_MEMBER_REENTRANCY_GUARD( bar1 )
* PCL_MEMBER_REENTRANCY_GUARD( bar2 )
*
* void bar1()
* {
* PCL_MEMBER_REENTRANCY_GUARDED_BEGIN( bar1 )
* // Protected code
* PCL_REENTRANCY_GUARDED_END
* }
*
* void bar2() const
* {
* PCL_MEMBER_REENTRANCY_GUARDED_BEGIN( bar2 )
* // Protected code
* PCL_REENTRANCY_GUARDED_END
* }
* }; \endcode
*
* In this example the bar1 and bar2 member functions are protected against
* reentrant execution. Note that reentrancy protection is a per-instance,
* function-specific property in this case: the bar1() and bar2() functions can
* be executed simultaneously for different objects, but they cannot be
* re-entered for the same instance. Since each member function uses its own
* reentrancy guard member in the foo class, each of them can safely call the
* other for the same object.
*
* See the AutoReentrancyGuard class for more information on the PCL
* implementation of reentrancy protection.
*
* \ingroup reentrancy_protection
*/
#define PCL_MEMBER_REENTRANCY_GUARD( member ) \
mutable pcl::AtomicInt __pcl_guard_##member##__;
/*!
* \def PCL_MEMBER_REENTRANCY_GUARDED_BEGIN
*
* This macro, along with PCL_MEMBER_REENTRANCY_GUARD and
* PCL_REENTRANCY_GUARDED_END, simplifies per-instance protection of specific
* non-reentrant member functions. See PCL_MEMBER_REENTRANCY_GUARD for an
* example.
*
* See the AutoReentrancyGuard class for more information on the PCL
* implementation of reentrancy protection.
*
* \ingroup reentrancy_protection
*/
#define PCL_MEMBER_REENTRANCY_GUARDED_BEGIN( member ) \
{ \
volatile pcl::AutoReentrancyGuard __a_r_g__( __pcl_guard_##member##__ );\
if ( __a_r_g__ ) \
{
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_Atomic_h
// ----------------------------------------------------------------------------
// EOF pcl/Atomic.h - Released 2022-03-12T18:59:29Z
-380
View File
@@ -1,380 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/AutoLock.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_AutoLock_h
#define __PCL_AutoLock_h
/// \file pcl/AutoLock.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/Atomic.h>
#include <pcl/Mutex.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class AutoLock
* \brief Automatic mutex lock/unlock.
*
* %AutoLock is a convenience class that simplifies using Mutex objects to
* protect code or data that can be accessed by multiple threads.
*
* An %AutoLock object locks a %Mutex object upon construction and unlocks it
* upon destruction. This ensures that the state of the %Mutex object will
* always be well defined, and that it will never be left locked, even in
* critical situations involving multiple function return points and
* exceptions.
*
* \sa AutoLockCounter, Mutex
*/
class PCL_CLASS AutoLock
{
public:
/*!
* Constructs an %AutoLock object to monitor a specified Mutex object.
*
* \param mutex A %Mutex object that will be monitored by this %AutoLock
* instance.
*
* The specified mutex object will be locked by this constructor. It will be
* unlocked automatically when this %AutoLock object gets out of scope, or
* if it is destroyed explicitly.
*/
explicit AutoLock( pcl::Mutex& mutex )
: m_mutex( &mutex )
{
Lock();
}
/*!
* Move constructor.
*/
AutoLock( AutoLock&& x )
: m_mutex( x.m_mutex )
, m_lock( x.m_lock )
{
x.m_mutex = nullptr;
}
/*!
* Destroys this %AutoLock object.
*
* If the monitored mutex object (that was specified in the constructor) is
* locked, it is unlocked by this destructor.
*/
~AutoLock()
{
Unlock();
m_mutex = nullptr;
}
/*!
* Copy constructor. This constructor is disabled because %AutoLock objects
* cannot be copied.
*/
AutoLock( const AutoLock& ) = delete;
/*!
* Copy assignment. This operator is disabled because %AutoLock objects
* cannot be copied.
*/
AutoLock& operator =( const AutoLock& ) = delete;
/*!
* Move assignment. This operator is disabled because %AutoLock objects
* cannot be move-assigned.
*/
AutoLock& operator =( AutoLock&& ) = delete;
/*!
* Locks the monitored mutex object, if it has not been previously locked by
* this object.
*/
void Lock()
{
if ( m_mutex != nullptr )
if ( m_lock.TestAndSet( 0, 1 ) )
m_mutex->Lock();
}
/*!
* Unlocks the monitored mutex object, if it has been previously locked by
* this object.
*/
void Unlock()
{
if ( m_mutex != nullptr )
if ( m_lock.TestAndSet( 1, 0 ) )
m_mutex->Unlock();
}
private:
pcl::Mutex* m_mutex = nullptr;
AtomicInt m_lock;
};
// ----------------------------------------------------------------------------
/*!
* \class AutoLockCounter
* \brief Automatic mutex lock/unlock with limited concurrent access allowance.
*
* %AutoLockCounter is similar to AutoLock: it allows protecting a section of
* code against concurrent thread access through a Mutex, with automatic
* lock/unlock operations upon object construction/destruction. However,
* %AutoLockCounter is slightly more complex because it can allow a specified
* amount of concurrent accesses, while %AutoLock forbids them completely.
*
* %AutoLockCounter is useful for scenarios where the protected code can
* exploit a resource concurrently, but only to a given extent that can be
* predicted or configured. Typical examples are routines performing file
* read/write operations.
*
* Example:
*
* \code
* void ParallelWriteFile( const String& filePath, const ByteArray& data, int limit )
* {
* static Mutex mutex;
* static AtomicInt count;
* volatile AutoLockCounter lock( mutex, count, limit );
* File::WriteFile( filePath, data );
* }
* \endcode
*
* In this example, the ParallelWriteFile routine allows creating and writing
* up to \e limit different disk files simultaneously. If \e limit files are
* already being written concurrently, a new call to ParallelWriteFile() will
* block the caller thread until at least one of the running tasks terminates.
*
* \sa AutoLock, Mutex, AtomicInt
*/
class PCL_CLASS AutoLockCounter
{
public:
/*!
* Constructs an %AutoLockCounter object to monitor a Mutex with automatic
* counting of lock operations and a given maximum number of concurrent
* accesses.
*
* \param mutex Reference to a Mutex object that will be monitored by this
* %AutoLockCounter instance.
*
* \param count Reference to an AtomicInt object that will be updated by
* this instance to control the current amount of concurrent
* accesses.
*
* \param limit Maximum number of concurrent accesses allowed. The
* specified \a count variable will be atomically incremented
* by this constructor. If \a count is greater than \a limit
* after the increment, this constructor will lock the
* specified \a mutex. Otherwise the mutex will not be locked
* automatically upon construction. Note that the mutex can
* be locked explicitly by calling the Lock() member function
* for any AutoLock or AutoLockCounter object sharing the
* same \a mutex variable.
*
* By specifying a \a limit of zero, no concurrent access will be allowed
* and this object will be functionally equivalent to an AutoLock instance
* monitoring the same \a mutex. By setting \a limit to a value greater than
* or equal to one, the protected code section will be allowed to run once,
* twice, etc. without a (potentially expensive) lock operation.
*
* If the specified \a mutex has been locked by this object, be it
* automatically or explicitly, it will be unlocked automatically when this
* %AutoLockCounter object is destroyed or gets out of scope.
*/
explicit AutoLockCounter( pcl::Mutex& mutex, AtomicInt& count, int limit )
: m_mutex( &mutex )
, m_count( &count )
, m_lock( 0 )
{
if ( m_count->FetchAndAdd( 1 ) >= limit-1 )
{
Lock();
if ( m_count->Load() < limit )
Unlock();
}
}
/*!
* Move constructor.
*/
AutoLockCounter( AutoLockCounter&& x )
: m_mutex( x.m_mutex )
, m_count( x.m_count )
, m_lock( x.m_lock )
{
x.m_mutex = nullptr;
x.m_count = nullptr;
}
/*!
* Destroys this %AutoLockCounter object.
*
* This destructor performs two separate actions:
*
* - If the monitored mutex (which was specified in the constructor) has
* been locked by this object, it will be unlocked. This applies both if the
* mutex has been locked automatically upon construction (because the
* monitored counter was larger than the specified limit), or explicitly by
* calling the Lock() member function for this object.
*
* - The monitored counter, which was atomically incremented upon
* construction, will be atomically decremented.
*/
~AutoLockCounter()
{
Unlock();
m_mutex = nullptr;
if ( m_count != nullptr )
{
m_count->Decrement();
m_count = nullptr;
}
}
/*!
* Copy constructor. This constructor is disabled because %AutoLockCounter
* objects cannot be copied.
*/
AutoLockCounter( const AutoLockCounter& ) = delete;
/*!
* Copy assignment. This operator is disabled because %AutoLockCounter
* objects cannot be copied.
*/
AutoLockCounter& operator =( const AutoLockCounter& ) = delete;
/*!
* Move assignment. This operator is disabled because %AutoLockCounter
* objects cannot be move-assigned.
*/
AutoLockCounter& operator =( AutoLockCounter&& ) = delete;
/*!
* Locks the monitored mutex object, if it has not been previously locked by
* this object.
*/
void Lock()
{
if ( m_mutex != nullptr )
if ( m_lock.TestAndSet( 0, 1 ) )
m_mutex->Lock();
}
/*!
* Unlocks the monitored mutex object, if it has been previously locked by
* this object.
*/
void Unlock()
{
if ( m_mutex != nullptr )
if ( m_lock.TestAndSet( 1, 0 ) )
m_mutex->Unlock();
}
private:
pcl::Mutex* m_mutex = nullptr;
AtomicInt* m_count = nullptr;
AtomicInt m_lock;
};
// ----------------------------------------------------------------------------
/*!
* \def Synchronized
* \brief A macro to protect a simple fragment of code with a Mutex object.
*
* Example of use:
*
* \code
* Mutex mutex;
* ...
* Synchronized( mutex, count += img.Width(); )
* \endcode
*
* The protected code should not contain tokens that could invalidate macro
* argument semantics. To synchronize more complex pieces of code, use an
* AutoLock object explicitly. For example:
*
* \code
* Mutex mutex;
* ...
* {
* AutoLock locker( mutex );
* ... some code to protect here ...
* }
* \endcode
*/
#define Synchronized( mutex, code ) \
{ \
pcl::AutoLock _________( mutex ); \
code \
}
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_AutoLock_h
// ----------------------------------------------------------------------------
// EOF pcl/AutoLock.h - Released 2022-03-12T18:59:29Z
-912
View File
@@ -1,912 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/AutoPointer.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_AutoPointer_h
#define __PCL_AutoPointer_h
/// \file pcl/AutoPointer.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/Utility.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class StandardDeleter
* \brief An object deleter that uses the standard delete operator.
*
* Deleter objects are used by smart pointer classes (e.g., AutoPointer) to
* destroy and deallocate dynamically allocated objects. A valid deleter class
* must implement the following member functions:
*
* \li Default constructor.
*
* \li Copy constructor.
*
* \li Move constructor.
*
* \li Function call operator with a single argument of type T* (pointer to T).
* This member function will destroy and deallocate the T object pointed to by
* its argument.
*
* \li Function call operator with a single argument of type T[] (array of T).
* This member function will destroy and deallocate a contiguous sequence of
* objects stored at the location pointed to by its argument.
*
* %StandardDeleter implements object and array destruction/deallocation by
* calling the standard \c delete operator.
*
* \sa AutoPointer, AutoPointerCloner
*/
template <typename T>
class PCL_CLASS StandardDeleter
{
public:
/*!
* Represents the type of objects to destroy and deallocate.
*/
typedef T value_type;
/*!
* Represents a pointer to an object to destroy and deallocate.
*/
typedef T* pointer;
/*!
* Function call operator. Destroys and deallocates the object pointed to by
* the specified pointer \a p.
*/
void operator()( pointer p ) const
{
PCL_PRECONDITION( p != nullptr )
delete p;
}
};
// ----------------------------------------------------------------------------
/*!
* \class AutoPointer
* \brief A smart pointer with exclusive object ownership and optional
* automatic object destruction.
*
* %AutoPointer stores a pointer to an object of which it is the sole owner.
* The owned object can optionally be destroyed when the owner %AutoPointer
* instance is destroyed.
*
* The template argument T represents the type of the objects owned by this
* template instantiation. The template argument D represents a functor class
* responsible for deletion of objects of type T. By default, %AutoPointer uses
* the StandardDeleter template class, which is a simple wrapper for the
* standard \c delete operator.
*
* Smart pointers are useful entities to guarantee proper destruction and
* deallocation of data in a variety of scenarios, such as exception driven
* code where the same objects have to be destroyed at different points in the
* execution workflow. For example, consider the following pseudocode:
*
* \code
* struct Foo { ... };
* void Bar()
* {
* Foo* one = nullptr, * two = nullptr;
* try
* {
* // ... some code that may create new Foo objects ...
* if ( condition1 ) one = new Foo;
* if ( condition2 ) two = new Foo;
* // ... some code that can throw exceptions ...
* if ( one != nullptr ) delete one;
* if ( two != nullptr ) delete two;
* }
* catch ( ... )
* {
* if ( one != nullptr ) delete one;
* if ( two != nullptr ) delete two;
* throw;
* }
* }
* \endcode
*
* Note that the objects pointed to by the \c one and \c two variables have to
* be destroyed at two locations: at the bottom of the \c try block (normal
* execution), and when an exception is caught, within the \c catch block. If
* the %Bar() routine were more complex, even more deallocations might be
* necessary at different locations, making the code intricate and prone to
* memory leaks.
*
* All of these complexities and potential problems can be avoided easily with
* smart pointers. For example, the following snippet would be equivalent to
* the pseudocode above:
*
* \code
* struct Foo { ... };
* void Bar()
* {
* AutoPointer<Foo> one, two;
* // ... some code that may create new Foo objects ...
* if ( condition1 ) one = new Foo;
* if ( condition2 ) two = new Foo;
* // ... some code that can throw exceptions ...
* }
* \endcode
*
* With smart pointers, there's no need to explicitly destroy the dynamically
* allocated objects \c one and \c two: The %AutoPointer objects will destroy
* and deallocate them automatically when they get out of scope. On the other
* hand, the %AutoPointer instances behave just like normal pointers allowing
* indirections, pointer assignments, and structure member selections for their
* owned objects transparently. The resulting code is simpler and more robust.
*
* By default, when an %AutoPointer instance is destroyed it also destroys the
* object pointed to by its contained pointer (if the %AutoPointer stores a
* non-null pointer). This <em>automatic deletion</em> feature can be disabled
* in some situations where a single %AutoPointer can store either a pointer to
* a dynamically allocated object, or a pointer to an already existing object
* that must be preserved (e.g., an object living in the stack). For example:
*
* \code
* void Foo( Image& image )
* {
* //
* // Extract the CIE L* component of a color image ...
* // ... or use the same image as the working lightness if it is grayscale.
* //
* AutoPointer<Image> lightness;
* if ( image.IsColor() )
* {
* lightness = new Image;
* image.ExtractLightness( *lightness );
* }
* else
* {
* lightness = &image;
* lightness.DisableAutoDelete();
* }
*
* DoSomeStuffWithTheLightnessComponent( *lightness );
*
* //
* // Insert the modified CIE L* component back in the color image.
* //
* if ( image.IsColor() )
* image.SetLightness( *lightness );
* }
* \endcode
*
* In the above code, the \c lightness variable can either store a newed image,
* if the passed \a image is a color image, or a pointer to \a image if it is a
* grayscale image. In the latter case we have disabled the automatic deletion
* feature for the \c lightness %AutoPointer, so it won't delete its stored
* pointer when it gets out of scope.
*
* \sa StandardDeleter, AutoPointerCloner
*/
template <class T, class D = StandardDeleter<T> >
class PCL_CLASS AutoPointer
{
public:
/*!
* Represents the type of the object pointed to by this smart pointer.
*/
typedef T value_type;
/*!
* Represents a pointer stored in this smart pointer.
*/
typedef T* pointer;
/*!
* Represents a pointer to an immutable object stored in this smart pointer.
*/
typedef const T* const_pointer;
/*!
* Represents the type of the object responsible for object deletion.
*/
typedef D deleter;
/*!
* Constructs a null smart pointer.
*
* \param autoDelete Initial state of the automatic deletion feature. The
* default value is true, so auto deletion is always
* enabled by default for newly created %AutoPointer
* objects.
*
* \param d Deleter object, responsible for object destruction
* when the automatic deletion feature is enabled.
*
* A null smart pointer stores a null pointer, so it does not point to a
* valid object.
*
* A copy of the specified deleter \a d will be used. If no deleter is
* specified, this object will use a default-constructed instance of the
* \a D template argument class.
*/
AutoPointer( bool autoDelete = true, const deleter& d = deleter() )
: m_deleter( d )
, m_autoDelete( autoDelete )
{
}
/*!
* Constructs a smart pointer to store a given pointer.
*
* \param p The pointer to store in this %AutoPointer instance.
*
* \param autoDelete Initial state of the automatic deletion feature. The
* default value is true, so auto deletion is always
* enabled by default for newly created %AutoPointer
* objects.
*
* \param d Deleter object, responsible for object destruction
* when the automatic deletion feature is enabled.
*
* A copy of the specified deleter \a d will be used. If no deleter is
* specified, this object will use a default-constructed instance of the
* \a D template argument class.
*/
AutoPointer( pointer p, bool autoDelete = true, const deleter& d = deleter() )
: m_deleter( d )
, m_autoDelete( autoDelete )
{
m_pointer = p;
}
/*!
* Non-trivial copy constructor. Constructs a smart pointer by transferring
* the pointer stored in another smart pointer \a x.
*
* The automatic deletion feature for this object will be in the same state
* as it is currently set for the source object \a x.
*
* The smart pointer \a x will transport a null pointer after this instance
* is constructed. This happens irrespective of the state of the automatic
* deletion feature. This guarantees that, as long as no two %AutoPointer
* instances have been \e explicitly constructed to store the same pointer,
* no two %AutoPointer instances can share the same pointer accidentally,
* and hence multiple deletions are not possible.
*/
AutoPointer( AutoPointer& x )
: m_deleter( x.m_deleter )
, m_autoDelete( x.m_autoDelete )
{
m_pointer = x.Release();
}
/*!
* Move constructor.
*/
AutoPointer( AutoPointer&& x )
: m_deleter( std::move( x.m_deleter ) )
, m_autoDelete( x.m_autoDelete )
{
m_pointer = x.Release();
}
/*!
* Destroys an %AutoPointer object.
*
* If this instance stores a non-null pointer, and the automatic deletion
* feature is enabled, the pointed object will be destroyed by calling the
* deleter object.
*/
virtual ~AutoPointer()
{
Reset();
}
/*!
* Causes this smart pointer to store the specified pointer \a p.
*
* If this instance stores a non-null pointer when this function is called,
* and the automatic deletion feature is enabled, the pointed object is
* destroyed by calling the deleter object.
*/
void SetPointer( pointer p )
{
if ( m_pointer != p )
{
if ( m_autoDelete )
if ( m_pointer != nullptr )
m_deleter( Release() ); // in case m_deleter throws
m_pointer = p;
}
}
/*!
* Causes this smart pointer to store a null pointer.
*
* If this instance stores a non-null pointer when this function is called,
* and the automatic deletion feature is enabled, the pointed object is
* destroyed by calling the deleter object.
*
* This member function is functionally equivalent to SetPointer( nullptr ).
*/
void Reset()
{
if ( m_pointer != nullptr )
{
pointer p = Release(); // in case m_deleter throws
if ( m_autoDelete )
m_deleter( p );
}
}
/*!
* A synonym for Reset(). Useful to enforce semantics when the smart pointer
* owns the pointed object.
*/
void Destroy()
{
Reset();
}
/*!
* Returns the pointer stored in this %AutoPointer, and causes this object
* to \e forget it by storing a null pointer.
*
* The object pointed is never destroyed by this function, irrespective of
* the state of automatic deletion. In this way, ownership of the pointed
* object (or more specifically, the responsibility for destroying it) is
* transferred to the caller.
*/
pointer Release()
{
pointer p = m_pointer;
m_pointer = nullptr;
return p;
}
/*!
* Returns a pointer to the immutable object pointed to by this %AutoPointer
* instance.
*/
const_pointer Pointer() const
{
return m_pointer;
}
/*!
* Returns a copy of the pointer stored in this %AutoPointer instance.
*/
pointer Pointer()
{
return m_pointer;
}
/*!
* A synonym for Pointer() const.
*/
const_pointer Ptr() const
{
return m_pointer;
}
/*!
* A synonym for Pointer().
*/
pointer Ptr()
{
return m_pointer;
}
/*!
* Returns true iff this smart pointer object stores a null pointer.
*/
bool IsNull() const
{
return m_pointer == nullptr;
}
/*!
* Returns true iff this smart pointer object stores a non-null pointer.
* Equivalent to !IsNull().
*/
bool IsValid() const
{
return !IsNull();
}
/*!
* Returns true iff the automatic deletion feature of %AutoPointer is
* currently enabled for this object.
*
* When automatic deletion is enabled, the object pointed to by this
* instance will be destroyed (by calling the deleter object) when this
* instance is destroyed, or when it is assigned with a different pointer.
*
* When automatic deletion is disabled, the pointed object will not be
* destroyed automatically.
*
* See the detailed description for the %AutoPointer class for more
* information, including code examples.
*
* \sa EnableAutoDelete(), DisableAutoDelete()
*/
bool IsAutoDelete() const
{
return m_autoDelete;
}
/*!
* Enables (or disables) the automatic deletion feature of %AutoPointer for
* this object.
*
* \sa IsAutoDelete(), DisableAutoDelete()
*/
void EnableAutoDelete( bool enable = true )
{
m_autoDelete = enable;
}
/*!
* Disables (or enables) the automatic deletion feature of %AutoPointer for
* this object.
*
* \sa IsAutoDelete(), EnableAutoDelete()
*/
void DisableAutoDelete( bool disable = true )
{
EnableAutoDelete( !disable );
}
/*!
* Returns a reference to the immutable deleter object in this instance.
*/
const deleter& Deleter() const
{
return m_deleter;
}
/*!
* Returns a reference to the deleter object in this instance.
*/
deleter& Deleter()
{
return m_deleter;
}
/*!
* Copy assignment operator. Transfers the pointer stored in another smart
* pointer to this object.
*
* This assignment operator performs the following actions:
*
* (1) If this smart pointer stores a valid (non-null) pointer, and the
* automatic deletion feature is enabled, the pointed object is destroyed by
* the deleter object.
*
* (2) The pointer stored in the other smart pointer \a x is copied to this
* instance.
*
* (3) The other smart pointer \a x is forced to store a null pointer.
*
* (4) Returns a reference to this object.
*
* This operator function does nothing if the specified %AutoPointer \a x
* stores the same pointer as this object. This prevents multiple deletions.
*/
AutoPointer& operator =( AutoPointer& x )
{
SetPointer( x.Release() );
m_deleter = x.m_deleter;
m_autoDelete = x.m_autoDelete;
return *this;
}
/*!
* Move assignment operator. For the %AutoPointer class, this member
* function performs the same actions as the copy assignment operator.
*/
AutoPointer& operator =( AutoPointer&& x )
{
SetPointer( x.Release() );
m_deleter = std::move( x.m_deleter );
m_autoDelete = x.m_autoDelete;
return *this;
}
/*!
* Causes this smart pointer to store the specified pointer \a p. Returns a
* reference to this object.
*
* If this instance stores a non-null pointer when this function is called,
* and the automatic deletion feature is enabled, the pointed object is
* destroyed by the deleter object.
*
* If this object already stores the specified pointer \a p, this function
* does nothing.
*
* This member function is equivalent to:
*
* \code
* SetPointer( p );
* \endcode
*/
AutoPointer& operator =( pointer p )
{
SetPointer( p );
return *this;
}
/*!
* Returns a pointer to the immutable object pointed to by this instance.
*
* This operator is a synonym for the Pointer() const member function.
*/
operator const_pointer() const
{
return m_pointer;
}
/*!
* Returns a copy of the pointer stored in this %AutoPointer instance.
*
* This operator is a synonym for the Pointer() member function.
*/
operator pointer()
{
return m_pointer;
}
/*!
* Structure member selection operator. Returns a pointer to the immutable
* object pointed to by this %AutoPointer instance.
*/
const_pointer operator ->() const
{
PCL_PRECONDITION( m_pointer != nullptr )
return m_pointer;
}
/*!
* Structure member selection operator. Returns a copy of the pointer stored
* in this %AutoPointer instance.
*/
pointer operator ->()
{
PCL_PRECONDITION( m_pointer != nullptr )
return m_pointer;
}
/*!
* Dereference operator. Returns a reference to the immutable object pointed
* to by this smart pointer.
*/
const value_type& operator *() const
{
PCL_PRECONDITION( m_pointer != nullptr )
return *m_pointer;
}
/*!
* Dereference operator. Returns a reference to the object pointed to by
* this smart pointer.
*/
value_type& operator *()
{
PCL_PRECONDITION( m_pointer != nullptr )
return *m_pointer;
}
/*!
* Returns true iff this smart pointer stores a non-null pointer. This
* operator is equivalent to !IsNull().
*/
operator bool() const
{
return !IsNull();
}
/*!
* Exchanges two smart pointers \a x1 and \a x2.
*/
friend void Swap( AutoPointer& x1, AutoPointer& x2 )
{
pcl::Swap( x1.m_pointer, x2.m_pointer );
pcl::Swap( x1.m_deleter, x2.m_deleter );
bool b = x1.m_autoDelete; x1.m_autoDelete = x2.m_autoDelete; x2.m_autoDelete = b;
}
protected:
pointer m_pointer = nullptr;
deleter m_deleter;
bool m_autoDelete = true;
};
// ----------------------------------------------------------------------------
#define ASSERT_COPIABLE_T() \
static_assert( std::is_copy_constructible<T>::value, "AutoPointerCloner<> requires a copy-constructible type." )
/*!
* \class AutoPointerCloner
* \brief A smart pointer able to generate dynamically allocated copies of the
* objects pointed to by other smart pointers.
*
* %AutoPointerCloner is like AutoPointer, from which it derives publicly, with
* the only and substantial difference that it makes a dynamically allocated
* copy (or \e clone) of the object pointed to by another smart pointer upon
* copy construction or copy assignment. This is useful in cases where a
* dynamically allocated data member object must be duplicated automatically by
* the copy constructors and copy assignment operator of its base class.
*
* \sa AutoPointer
*/
template <class T, class D = StandardDeleter<T> >
class PCL_CLASS AutoPointerCloner : public AutoPointer<T,D>
{
public:
typedef AutoPointer<T,D> base_type;
/*!
* Represents the type of the object pointed to by this smart pointer.
*/
typedef typename base_type::value_type value_type;
/*!
* Represents a pointer stored in this smart pointer.
*/
typedef typename base_type::pointer pointer;
/*!
* Represents a pointer to an immutable object stored in this smart pointer.
*/
typedef typename base_type::const_pointer const_pointer;
/*!
* Represents the type of the object responsible for object deletion.
*/
typedef typename base_type::deleter deleter;
/*!
* Constructs a null smart pointer cloner.
*
* \param autoDelete Initial state of the automatic deletion feature. The
* default value is true, so auto deletion is always
* enabled by default for newly created %AutoPointer
* objects.
*
* \param d Deleter object, responsible for object destruction
* when the automatic deletion feature is enabled.
*
* A null smart pointer stores a null pointer, so it does not point to a
* valid object.
*
* A copy of the specified deleter \a d will be used. If no deleter is
* specified, this object will use a default-constructed instance of the
* deleter template argument class.
*/
AutoPointerCloner( bool autoDelete = true, const deleter& d = deleter() )
: base_type( autoDelete, d )
{
ASSERT_COPIABLE_T();
}
/*!
* Constructs a smart pointer cloner to store a given pointer.
*
* \param p The pointer to store in this %AutoPointer instance.
*
* \param autoDelete Initial state of the automatic deletion feature. The
* default value is true, so auto deletion is always
* enabled by default for newly created %AutoPointer
* objects.
*
* \param d Deleter object, responsible for object destruction
* when the automatic deletion feature is enabled.
*
* A copy of the specified deleter \a d will be used. If no deleter is
* specified, this object will use a default-constructed instance of the
* deleter template argument class.
*/
AutoPointerCloner( pointer p, bool autoDelete = true, const deleter& d = deleter() )
: base_type( p, autoDelete, d )
{
ASSERT_COPIABLE_T();
}
/*!
* Non-trivial copy constructor. Constructs a smart pointer cloner by making
* a dynamically allocated copy (or \e clone) of the object pointed to by
* the pointer stored in another smart pointer \a x.
*
* The automatic deletion feature will be enabled for this object if a clone
* object is generated; otherwise it will be in the same state as it is
* currently set for the source object \a x.
*
* Contrarily to the copy constructor of AutoPointer, the source smart
* pointer \a x will not be modified in any way by this constructor.
*/
AutoPointerCloner( const base_type& x )
: base_type( nullptr )
{
ASSERT_COPIABLE_T();
this->m_pointer = x ? new value_type( *x ) : nullptr;
this->m_deleter = x.m_deleter;
this->m_autoDelete = x || x.m_autoDelete;
}
/*!
* Copy constructor. Constructs a smart pointer cloner by making a
* dynamically allocated copy (or \e clone) of the object pointed to by
* the pointer stored in another smart pointer cloner \a x.
*
* The automatic deletion feature will be enabled for this object if a clone
* object is generated; otherwise it will be in the same state as it is
* currently set for the source object \a x.
*
* Contrarily to the copy constructor of AutoPointer, the source smart
* pointer \a x will not be modified in any way by this constructor.
*/
AutoPointerCloner( const AutoPointerCloner& x )
: base_type( nullptr )
{
ASSERT_COPIABLE_T();
this->m_pointer = x ? new value_type( *x ) : nullptr;
this->m_deleter = x.m_deleter;
this->m_autoDelete = x || x.m_autoDelete;
}
/*!
* Move constructor.
*/
AutoPointerCloner( base_type&& x )
: base_type( std::move( x ) )
{
}
/*!
* Copy assignment from base class operator.
*
* This assignment operator performs the following actions:
*
* (1) If this smart pointer stores a valid (non-null) pointer, and the
* automatic deletion feature is enabled, the pointed object is destroyed by
* the deleter object. This behavior is the same as for AutoPointer.
*
* (2) If the other smart pointer \a x stores a valid (non-null) pointer,
* a dynamically allocated copy (or \e clone) of the pointed object will be
* generated, and a pointer to the newly constructed object will be stored
* in this instance. In such case, the automatic deletion feature will be
* enabled for this object; otherwise, it will have the same state as in the
* source object \a x, and this object will store a null pointer.
*
* (3) Returns a reference to this object.
*
* In contrast to AutoPointer's copy assignment operator, this operator does
* not modify the specified source object \a x in any way.
*/
AutoPointerCloner& operator =( const base_type& x )
{
this->SetPointer( x ? new value_type( *x ) : nullptr );
this->m_deleter = x.m_deleter;
this->m_autoDelete = x || x.m_autoDelete;
return *this;
}
/*!
* Copy assignment operator.
*
* This assignment operator performs the following actions:
*
* (1) If this smart pointer stores a valid (non-null) pointer, and the
* automatic deletion feature is enabled, the pointed object is destroyed by
* the deleter object. This behavior is the same as for AutoPointer.
*
* (2) If the other smart pointer \a x stores a valid (non-null) pointer,
* a dynamically allocated copy (or \e clone) of the pointed object will be
* generated, and a pointer to the newly constructed object will be stored
* in this instance. In such case, the automatic deletion feature will be
* enabled for this object; otherwise, it will have the same state as in the
* source object \a x, and this object will store a null pointer.
*
* (3) Returns a reference to this object.
*
* In contrast to AutoPointer's copy assignment operator, this operator does
* not modify the specified source object \a x in any way.
*/
AutoPointerCloner& operator =( const AutoPointerCloner& x )
{
this->SetPointer( x ? new value_type( *x ) : nullptr );
this->m_deleter = x.m_deleter;
this->m_autoDelete = x || x.m_autoDelete;
return *this;
}
/*!
* Move assignment operator. This function simply calls the base class
* version of the same operator and returns a reference to this object.
*/
AutoPointerCloner& operator =( base_type&& x )
{
(void)base_type::operator =( std::move( x ) );
return *this;
}
/*!
* Causes this smart pointer cloner to store the specified pointer \a p.
* Returns a reference to this object.
*
* This member function is identical to its base class counterpart
* AutoPointer::operator =( pointer ). It is equivalent to:
*
* \code SetPointer( p ); \endcode
*/
AutoPointerCloner& operator =( pointer p )
{
this->SetPointer( p );
return *this;
}
};
#undef ASSERT_COPIABLE_T
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_AutoPointer_h
// ----------------------------------------------------------------------------
// EOF pcl/AutoPointer.h - Released 2022-03-12T18:59:29Z
-233
View File
@@ -1,233 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/AutoStatusCallbackRestorer.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_AutoStatusCallbackRestorer_h
#define __PCL_AutoStatusCallbackRestorer_h
/// \file pcl/AutoStatusCallbackRestorer.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/StatusMonitor.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class AutoStatusCallbackRestorer
* \brief Automatic recovery of status monitoring callbacks.
*
* %AutoStatusCallbackRestorer simplifies working with different status
* monitoring callback objects, including objects allocated as automatic
* variables (i.e., inside functions without the static qualifier), ensuring
* that the initial monitoring callback will be recovered when the instance
* gets out of scope.
*
* An instance of %AutoStatusCallbackRestorer stores a pointer to the
* StatusCallback object being used by a StatusMonitor instance upon
* construction, and restores it upon destruction. This ensures that the
* %StatusMonitor object will always be left in a valid state, even in critical
* situations involving multiple function return points and exceptions.
*
* Consider the following example:
*
* \code
* void Foo( Image& image )
* {
* StatusCallback* oldStatus = image.StatusCallback();
* StandardStatus status;
* image.SetStatusCallback( &status );
* image.Status().Initialize( "Performing Foo()", image.NumberOfPixels() );
* image.Status().DisableInitialization();
*
* try
* {
* DoFoo( image );
* image.SetStatusCallback( oldStatus );
* }
* catch ( ... )
* {
* image.SetStatusCallback( oldStatus );
* throw;
* }
* }
* \endcode
*
* Since \c status is an automatic variable, we cannot return from the Foo()
* function without removing it from image.Status(), because otherwise the
* StatusMonitor object would be referencing a dangling pointer. For this
* reason we have to be careful to restore the \c oldStatus pointer before
* returning from Foo(), including any possible returning points and all
* exceptions thrown.
*
* With %AutoStatusCallbackRestorer the above code can be simplified to:
*
* \code
* void Foo( Image& image )
* {
* AutoStatusCallbackRestorer saveStatus( image.Status() );
* StandardStatus status;
* image.SetStatusCallback( &status );
* image.Status().Initialize( "Performing Foo()", image.NumberOfPixels() );
* image.Status().DisableInitialization();
* DoFoo( image );
* }
* \endcode
*
* Note that the try-catch blocks are now unnecessary. As soon as the
* \c saveStatus variable gets out of scope, the \c image.Status() object will
* use its previous status callback again, that is, the same status callback
* that it was using before calling Foo(). This will happen automatically,
* including both normal function returns and uncaught exceptions within the
* Foo() function.
*
* \sa StatusMonitor, StatusCallback
*/
class PCL_CLASS AutoStatusCallbackRestorer
{
public:
/*!
* Constructs an %AutoStatusCallbackRestorer object for the specified
* client status \a monitor.
*
* \param monitor Reference to the client StatusMonitor instance. This
* object will store a pointer to the StatusCallback
* object currently being used by the client \a monitor.
*
* \warning The specified \a monitor object must remain valid while this
* object exists. Otherwise undefined behavior will be invoked when this
* object is destroyed.
*/
explicit AutoStatusCallbackRestorer( StatusMonitor& monitor )
: m_monitor( monitor )
{
Store();
}
/*!
* Destroys this %AutoStatusCallbackRestorer object.
*
* This destructor restores the status callback being used by the client
* status monitor when this object was constructed, or upon the last call to
* Store().
*/
~AutoStatusCallbackRestorer()
{
Restore();
}
/*!
* Restores the status callback that was being used by the client status
* monitor when this object was constructed, or upon the last call to
* Store().
*/
void Restore()
{
m_monitor.m_callback = m_callback;
}
/*!
* Stores the status callback currently used by the client status monitor.
*/
void Store()
{
m_callback = m_monitor.m_callback;
}
/*!
* Returns a reference to the client status monitor object. The client
* status monitor has been specified upon construction of this instance and
* cannot be changed.
*/
StatusMonitor& Monitor() const
{
return m_monitor;
}
/*!
* Returns the address of the status callback object currently stored by
* this instance. This is a pointer to a StatusCallback object that was
* acquired when this object was constructed, or in the last call to the
* Store() member function.
*/
StatusCallback* Callback() const
{
return m_callback;
}
/*!
* Copy constructor. This constructor is disabled.
*/
AutoStatusCallbackRestorer( const AutoStatusCallbackRestorer& ) = delete;
/*!
* Copy assignment. This constructor is disabled.
*/
AutoStatusCallbackRestorer& operator =( const AutoStatusCallbackRestorer& ) = delete;
private:
StatusMonitor& m_monitor;
StatusCallback* m_callback = nullptr;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_AutoStatusCallbackRestorer_h
// ----------------------------------------------------------------------------
// EOF pcl/AutoStatusCallbackRestorer.h - Released 2022-03-12T18:59:29Z
-345
View File
@@ -1,345 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/AutoViewLock.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_AutoViewLock_h
#define __PCL_AutoViewLock_h
/// \file pcl/AutoViewLock.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/Atomic.h>
#include <pcl/View.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class AutoViewLock
* \brief Automatic view lock/unlock.
*
* %AutoViewLock simplifies locking and unlocking View objects accessed from
* process execution routines.
*
* An %AutoViewLock object locks a %View upon construction and unlocks it upon
* destruction. This ensures that a view will never be left locked, even in
* critical situations involving multiple function return points and
* exceptions.
*
* %AutoViewLock works for %View just as AutoLock does for Mutex. The main
* difference is that a view can be locked and unlocked for read and write
* operations separately, while a mutex cannot.
*
* Typically %AutoViewLock is used within a reimplementation of the
* ProcessImplementation::ExecuteOn() virtual member function for a process
* instance class. Consider the following example:
*
* \code
* bool FooProcessInstance::ExecuteOn( View& view )
* {
* try
* {
* view.Lock();
*
* ImageVariant image = view.Image();
*
* if ( image.IsComplexSample() )
* {
* view.Unlock();
* return false;
* }
*
* Console().EnableAbort();
*
* StandardStatus status;
* image->SetStatusCallback( &status );
*
* FooEngine::Apply( image, *this );
*
* view.Unlock();
* return true;
* }
* catch ( ... )
* {
* view.Unlock();
* throw;
* }
* }
* \endcode
*
* With %AutoViewLock the above code can be simplified considerably:
*
* \code
* bool FooProcessInstance::ExecuteOn( View& view )
* {
* AutoViewLock lock( view );
*
* ImageVariant image = view.Image();
*
* if ( image.IsComplexSample() )
* return false;
*
* Console().EnableAbort();
*
* StandardStatus status;
* image->SetStatusCallback( &status );
*
* FooEngine::Apply( image, *this );
*
* return true;
* }
* \endcode
*
* Note that the try-catch blocks are now unnecessary. As soon as the \c lock
* variable gets out of scope, the \c view object will be unlocked
* automatically, including both normal function returns and uncaught
* exceptions within the ExecuteOn() function. Keep in mind that all exceptions
* will always be caught by internal PCL routines.
*
* \sa View
*/
class PCL_CLASS AutoViewLock
{
public:
/*!
* Constructs an %AutoViewLock object to monitor the specified \a view.
*
* \param view A %View object that will be monitored by this
* %AutoViewLock instance. The object must remain valid for
* the whole lifetime of this %AutoViewLock instance.
*
* \param lock Whether the specified \a view should be locked for read
* and write operations by this constructor. The default
* value is true.
*
* If the \a lock argument is true, the specified \a view will be locked for
* read and write operations immediately by this constructor. It will be
* unlocked automatically when this %AutoViewLock object gets out of scope,
* or if it is destroyed explicitly.
*
* By specifying \a lock=false, you can create an %AutoViewLock object to
* monitor a view and lock it for write operations exclusively:
*
* \code
* void foo( View& view )
* {
* AutoViewLock lock( view, false ); // do not lock for read-write ops.
* lock.LockForWrite();
* ...
* }
* \endcode
*
* See AutoViewWriteLock for a convenience class to implements this
* functionality in a cleaner way.
*/
explicit AutoViewLock( View& view, bool lock = true )
: m_view( view )
, m_readLock( 0 )
, m_writeLock( 0 )
{
if ( lock )
Lock();
}
/*!
* Destroys this %AutoViewLock object.
*
* If the monitored view (that was specified in the constructor) is locked,
* it is unlocked by this destructor.
*/
~AutoViewLock()
{
Unlock();
m_view = View::Null();
}
/*!
* Copy constructor. This constructor is disabled because views and view
* locks are unique objects.
*/
AutoViewLock( const AutoViewLock& ) = delete;
/*!
* Copy assignment. This operator is disabled because views and view locks
* are unique objects.
*/
AutoViewLock& operator =( const AutoViewLock& ) = delete;
/*!
* Locks the monitored view for read and write operations, if it has not
* been previously locked.
*
* For more information, see the documentation for View::Lock().
*/
void Lock()
{
if ( !m_view.IsNull() )
{
int unlocked = 0;
if ( m_readLock.TestAndSet( 0, 1 ) )
++unlocked;
if ( m_writeLock.TestAndSet( 0, 1 ) )
++unlocked;
if ( unlocked )
m_view.Lock();
}
}
/*!
* Unlocks the monitored view for read and write operations, if it has been
* previously locked.
*
* For more information, see the documentation for View::Unlock().
*/
void Unlock()
{
if ( !m_view.IsNull() )
{
int locked = 0;
if ( m_readLock.TestAndSet( 1, 0 ) )
++locked;
if ( m_writeLock.TestAndSet( 1, 0 ) )
++locked;
if ( locked )
m_view.Unlock();
}
}
/*!
* Locks the monitored view for write operations, if it has not already been
* write-locked.
*
* For more information, see the documentation for View::LockForWrite().
*/
void LockForWrite()
{
if ( !m_view.IsNull() )
if ( m_writeLock.TestAndSet( 0, 1 ) )
m_view.LockForWrite();
}
/*!
* Unlocks the monitored view for read operations, if it has already been
* read-locked.
*
* For more information, see the documentation for View::UnlockForRead().
*/
void UnlockForRead()
{
if ( !m_view.IsNull() )
if ( m_readLock.TestAndSet( 1, 0 ) )
m_view.UnlockForRead();
}
/*!
* Unlocks the monitored view for read operations only, if it has not
* already been unlocked.
*
* For more information, see the documentation for View::RelockForRead().
*/
void RelockForRead()
{
if ( !m_view.IsNull() )
if ( m_readLock.TestAndSet( 0, 1 ) )
m_view.RelockForRead();
}
private:
View m_view;
AtomicInt m_readLock;
AtomicInt m_writeLock;
};
/*!
* \class AutoViewWriteLock
* \brief Automatic write-only view lock/unlock.
*
* %AutoViewWriteLock performs automatic write-only locking/unlocking of View
* objects. See the documentation for the base class, AutoViewLock, for
* complete information.
*
* \sa View, AutoViewLock
*/
class PCL_CLASS AutoViewWriteLock : public AutoViewLock
{
public:
/*!
* Constructs an %AutoViewWriteLock object to monitor the specified \a view
* and lock it for write operations exclusively.
*
* This constructor is equivalent to the following:
*
* \code
* AutoViewLock lock( view, false ); // do not lock for read-write ops.
* lock.LockForWrite();
* \endcode
*/
explicit AutoViewWriteLock( View& view )
: AutoViewLock( view, false/*lock*/ )
{
LockForWrite();
}
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_AutoViewLock_h
// ----------------------------------------------------------------------------
// EOF pcl/AutoViewLock.h - Released 2022-03-12T18:59:29Z
-670
View File
@@ -1,670 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/BicubicFilterInterpolation.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_BicubicFilterInterpolation_h
#define __PCL_BicubicFilterInterpolation_h
/// \file pcl/BicubicFilterInterpolation.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/BidimensionalInterpolation.h>
#include <pcl/Math.h>
#include <pcl/Utility.h>
#include <pcl/Vector.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class CubicFilter
* \brief Mitchell-Netravali parameterized cubic filters.
*
* %CubicFilter implements a two-parameter, separable cubic filter as described
* in Don P. Mitchell, Arun N. Netravali (1988), <em>%Reconstruction Filters in
* %Computer %Graphics</em>, %Computer %Graphics, Vol. 22, No. 4, pp. 221-228.
*
* The family of cubic filters designed by Mitchell and Netravali has two
* parameters called B and C. Although these parameters can take any values,
* the authors recommend values pertaining to the line B + 2C = 1. In
* particular, the filter defined by B=C=1/3 has been proven to have excellent
* characteristics for a wide range of image reconstruction tasks.
*
* \sa MitchellNetravaliCubicFilter, CatmullRomSplineFilter, CubicBSplineFilter
*/
class PCL_CLASS CubicFilter
{
public:
/*!
* Constructs a new %CubicFilter object with the specified filter
* parameters \a B and \a C.
*/
CubicFilter( double B, double C )
: m_B( B )
, m_C( C )
{
m_k31 = ( 12 - 9*m_B - 6*m_C)/6;
m_k21 = (-18 + 12*m_B + 6*m_C)/6;
m_k01 = ( 6 - 2*m_B )/6;
m_k32 = ( -m_B - 6*m_C)/6;
m_k22 = ( 6*m_B + 30*m_C)/6;
m_k12 = ( -12*m_B - 48*m_C)/6;
m_k02 = ( 8*m_B + 24*m_C)/6;
}
/*!
* Copy constructor.
*/
CubicFilter( const CubicFilter& ) = default;
/*!
* Virtual destructor.
*/
virtual ~CubicFilter()
{
}
/*!
* Assignment operator.
*/
CubicFilter& operator =( const CubicFilter& ) = default;
/*!
* Evaluates this cubic filter for \a x.
*
* \note For performance reasons, this function returns an invalid value
* outside the range ]-2,+2[, which is the support of Mitchell-Netravali
* cubic filters. Strictly, zero should be returned outside the support
* range, but since this is a performance-critical routine, we have
* sacrified strictness for the sake of optimization. This function should
* never be called for Abs( \a x ) >= 2.
*/
PCL_HOT_FUNCTION
double operator()( double x ) const noexcept
{
if ( x < 0 )
x = -x;
return (x < 1) ? m_k01 + x*x*(m_k21 + x*m_k31) :
m_k02 + x*(m_k12 + x*(m_k22 + x*m_k32));
}
/*!
* Returns the filter's \e width, measured from the origin to its cutoff
* point. We define the \e support of a (symmetric) filter as the range
* ]-width,+width[.
*
* Mitchell-Netravali cubic filters are zero outside the range ]-2,+2[,
* hence this function always returns 2.
*/
double Width() const noexcept
{
return 2.0;
}
/*!
* Returns a descriptive text string for this cubic filter.
*/
virtual String Description() const
{
return String().Format( "Cubic filter (B=%.6f, C=%.6f)", m_B, m_C );
}
/*!
* Returns a pointer to a dynamically allocated duplicate of this filter.
*/
virtual CubicFilter* Clone() const
{
return new CubicFilter( *this );
}
protected:
double m_k31, m_k21, m_k01, m_k32, m_k22, m_k12, m_k02;
private:
double m_B, m_C; // for reference only; not used in calculations
};
/*!
* \class MitchellNetravaliCubicFilter
* \brief Mitchell-Netravali cubic filter with B=C=1/3
*
* This is the cubic filter recommended by Mitchell and Netravali (1988). It is
* implemented as a CubicFilter with parameters B=1/3 and C=1/3.
*
* \sa CubicFilter, CatmullRomSplineFilter, CubicBSplineFilter
*/
class PCL_CLASS MitchellNetravaliCubicFilter : public CubicFilter
{
public:
/*!
* Constructs a new %MitchellNetravaliCubicFilter object.
*/
MitchellNetravaliCubicFilter()
: CubicFilter( 1.0/3, 1.0/3 )
{
}
/*!
* Copy constructor.
*/
MitchellNetravaliCubicFilter( const MitchellNetravaliCubicFilter& ) = default;
/*!
* Virtual destructor.
*/
virtual ~MitchellNetravaliCubicFilter()
{
}
/*!
*/
String Description() const override
{
return "Mitchell-Netravali cubic filter";
}
/*!
*/
CubicFilter* Clone() const override
{
return new MitchellNetravaliCubicFilter( *this );
}
};
/*!
* \class CatmullRomSplineFilter
* \brief Catmull-Rom spline filter
*
* The Catmull-Rom spline filter is implemented as a CubicFilter with
* parameters B=0 and C=0.5.
*
* \sa CubicFilter, MitchellNetravaliCubicFilter, CubicBSplineFilter
*/
class PCL_CLASS CatmullRomSplineFilter : public CubicFilter
{
public:
/*!
* Constructs a new %CatmullRomSplineFilter object.
*/
CatmullRomSplineFilter()
: CubicFilter( 0, 0.5 )
{
}
/*!
* Copy constructor.
*/
CatmullRomSplineFilter( const CatmullRomSplineFilter& ) = default;
/*!
* Virtual destructor.
*/
virtual ~CatmullRomSplineFilter()
{
}
/*!
*/
String Description() const override
{
return "Catmull-Rom spline filter";
}
/*!
*/
CubicFilter* Clone() const override
{
return new CatmullRomSplineFilter( *this );
}
};
/*!
* \class CubicBSplineFilter
* \brief Cubic B-spline filter
*
* The cubic B-spline filter is implemented as a CubicFilter with
* parameters B=1 and C=0.
*
* \sa CubicFilter, MitchellNetravaliCubicFilter, CatmullRomSplineFilter
*/
class PCL_CLASS CubicBSplineFilter : public CubicFilter
{
public:
/*!
* Constructs a new %CubicBSplineFilter object.
*/
CubicBSplineFilter()
: CubicFilter( 1, 0 )
{
}
/*!
* Copy constructor.
*/
CubicBSplineFilter( const CubicBSplineFilter& ) = default;
/*!
* Virtual destructor.
*/
virtual ~CubicBSplineFilter()
{
}
/*!
*/
String Description() const override
{
return "Cubic B-spline filter";
}
/*!
*/
CubicFilter* Clone() const override
{
return new CubicBSplineFilter( *this );
}
};
// ----------------------------------------------------------------------------
#define m_width this->m_width
#define m_height this->m_height
#define m_fillBorder this->m_fillBorder
#define m_fillValue this->m_fillValue
#define m_data this->m_data
// ----------------------------------------------------------------------------
/*!
* \class BicubicFilterInterpolation
* \brief Bicubic filter interpolation algorithms.
*
* Bicubic filter interpolation uses a \e cubic \e filter (an instance of
* CubicFilter or a derived class) to interpolate pixel values in a rectangular
* pixel matrix of the specified horizontal and vertical \e radii. Thanks to
* the separability of cubic filters, %BicubicFilterInterpolation can be
* applied with a different filter size on each axis.
*
* \sa BidimensionalInterpolation, CubicFilter, MitchellNetravaliCubicFilter,
* CatmullRomSplineFilter, CubicBSplineFilter, NearestNeighborInterpolation,
* BilinearInterpolation, BicubicSplineInterpolation,
* BicubicBSplineInterpolation, LanczosInterpolation
*/
template <typename T>
class PCL_CLASS BicubicFilterInterpolation : public BidimensionalInterpolation<T>
{
public:
/*!
* Constructs a new %BicubicFilterInterpolation instance.
*
* \param rx,ry Horizontal and vertical interpolation radii, respectively,
* in pixels. Both radii must be >= 1. Interpolation will
* take place in a rectangular pixel matrix with 2*rx + 1
* columns and 2*ry + 1 rows.
*
* \param filter Reference to a CubicFilter instance that will be used as
* the interpolation filter.
*/
BicubicFilterInterpolation( int rx, int ry, const CubicFilter& filter )
: m_rx( Max( 1, rx ) )
, m_ry( Max( 1, ry ) )
, m_filter( filter )
{
PCL_PRECONDITION( rx >= 1 )
PCL_PRECONDITION( ry >= 1 )
Initialize();
}
/*!
* Copy constructor.
*/
BicubicFilterInterpolation( const BicubicFilterInterpolation& ) = default;
/*!
* Virtual destructor.
*/
virtual ~BicubicFilterInterpolation()
{
}
/*!
*/
void Initialize( const T* data, int dataWidth, int dataHeight ) override
{
BidimensionalInterpolation<T>::Initialize( data, dataWidth, dataHeight );
if ( m_rx > m_width || m_ry > m_height )
{
m_rx = Min( m_rx, m_width );
m_ry = Min( m_ry, m_height );
Initialize();
}
}
/*!
* Returns an interpolated value at {\a x,\a y} location.
*
* \param x,y Coordinates of the interpolation point (horizontal,vertical).
*
* %Interpolation takes place on a rectangular matrix whose center is the
* nearest pixel to {\a x, \a y}. The interpolation matrix has 2*rx + 1
* columns and 2*ry + 1 rows, where rx and ry are the horizontal and
* vertical interpolation radii, respectively.
*/
PCL_HOT_FUNCTION
double operator()( double x, double y ) const override
{
PCL_PRECONDITION( m_data != nullptr )
PCL_PRECONDITION( m_width > 0 && m_height > 0 )
PCL_PRECONDITION( x >= 0 && x < m_width )
PCL_PRECONDITION( y >= 0 && y < m_height )
PCL_CHECK( m_rx >= 1 && m_rx <= m_width )
PCL_CHECK( m_ry >= 1 && m_ry <= m_height )
PCL_CHECK( !m_k.IsEmpty() )
int x0 = Range( RoundInt( x ), 0, m_width-1 );
int y0 = Range( RoundInt( y ), 0, m_height-1 );
double dx = x - x0;
double dy = y - y0;
int64 d = int64( y0 - m_ry )*m_width + x0 - m_rx;
if ( m_rx >= m_ry )
{
double wx = 0;
for ( int xi = -m_rx, c = 0; xi <= m_rx; ++xi, ++c )
wx += (m_k[c] = m_filter( m_sx*(xi - dx) ));
double sy = 0, wy = 0;
for ( int yi = -m_ry; yi <= m_ry; ++yi )
{
double ky = m_filter( m_sy*(yi - dy) );
wy += ky;
const T* p;
int y = y0 + yi;
if ( y < 0 )
{
d += m_width;
if ( m_fillBorder )
{
sy += m_fillValue * ky;
continue;
}
p = m_data + (d - 2*int64( m_width )*(y + 1));
}
else if ( y >= m_height )
{
if ( m_fillBorder )
{
sy += m_fillValue * ky;
continue;
}
p = m_data + (d -= m_width);
}
else
{
p = m_data + d;
d += m_width;
}
int x = x0 - m_rx;
int x2 = x0 + m_rx;
int x1 = Min( x2, m_width-1 );
double sx = 0;
const double* kx = m_k.Begin();
while ( x < 0 )
{
++x;
++p;
sx += (m_fillBorder ? m_fillValue : double( *(p - (x + x)) )) * *kx++;
}
for ( ;; )
{
sx += *p++ * *kx++;
if ( ++x > x1 )
break;
}
while ( x <= x2 )
{
sx += (m_fillBorder ? m_fillValue : double( *--p )) * *kx++;
++x;
}
sy += sx/wx * ky;
}
return sy/wy;
}
else
{
double wy = 0;
for ( int yi = -m_ry, r = 0; yi <= m_ry; ++yi, ++r )
wy += (m_k[r] = m_filter( m_sy*(yi - dy) ));
double sx = 0, wx = 0;
for ( int xi = -m_rx; xi <= m_rx; ++xi )
{
double kx = m_filter( m_sx*(xi - dx) );
wx += kx;
const T* p;
int x = x0 + xi;
if ( x < 0 )
{
++d;
if ( m_fillBorder )
{
sx += m_fillValue * kx;
continue;
}
p = m_data + (d - 2*(x + 1));
}
else if ( x >= m_width )
{
if ( m_fillBorder )
{
sx += m_fillValue * kx;
continue;
}
p = m_data + --d;
}
else
p = m_data + d++;
int y = y0 - m_ry;
int y2 = y0 + m_ry;
int y1 = Min( y2, m_height-1 );
double sy = 0;
const double* ky = m_k.Begin();
while ( y < 0 )
{
++y;
p += m_width;
sy += (m_fillBorder ? m_fillValue : double( *(p - (y + y)*m_width) )) * *ky++;
}
for ( ;; )
{
sy += *p * *ky++;
p += m_width;
if ( ++y > y1 )
break;
}
while ( y <= y2 )
{
sy += (m_fillBorder ? m_fillValue : double( *(p -= m_width) )) * *ky++;
++y;
}
sx += sy/wy * kx;
}
return sx/wx;
}
}
/*!
* Returns the horizontal interpolation radius in pixels.
*/
int HorizontalRadius() const noexcept
{
return m_rx;
}
/*!
* Returns the vertical interpolation radius in pixels.
*/
int VerticalRadius() const noexcept
{
return m_ry;
}
/*!
* Sets new interpolation radii.
*
* \param rx,ry Horizontal and vertical interpolation radii, respectively,
* in pixels. Both radii must be >= 1. Interpolation will
* take place in a rectangular pixel matrix with 2*rh + 1
* columns and 2*rv + 1 rows.
*/
void SetRadii( int rx, int ry )
{
if ( rx != m_rx || ry != m_ry )
{
m_rx = Max( 1, rx );
m_ry = Max( 1, ry );
if ( this->data != nullptr )
{
if ( m_rx > m_width )
m_rx = m_width;
if ( m_ry > m_height )
m_ry = m_height;
}
Initialize();
}
}
/*!
* Returns a constant reference to the cubic filter being used by this
* interpolation.
*/
const CubicFilter& Filter() const noexcept
{
return m_filter;
}
/*!
* Sets a new cubic \a filter to be applied by this interpolation.
*/
void SetFilter( const CubicFilter& filter )
{
m_filter = filter;
Initialize();
}
protected:
int m_rx, m_ry; // horizontal and vertical radii
double m_sx, m_sy; // filter scaling ratios
mutable DVector m_k; // workspace for interpolated values
CubicFilter m_filter;
void Initialize()
{
m_sx = m_filter.Width()/(m_rx + 0.5);
m_sy = m_filter.Width()/(m_ry + 0.5);
m_k = DVector( 1 + (Max( m_rx, m_ry ) << 1) );
}
};
// ----------------------------------------------------------------------------
#undef m_width
#undef m_height
#undef m_fillBorder
#undef m_fillValue
#undef m_data
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BicubicFilterInterpolation_h
// ----------------------------------------------------------------------------
// EOF pcl/BicubicFilterInterpolation.h - Released 2022-03-12T18:59:29Z
-791
View File
@@ -1,791 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/BicubicInterpolation.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_BicubicInterpolation_h
#define __PCL_BicubicInterpolation_h
/// \file pcl/BicubicInterpolation.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/BidimensionalInterpolation.h>
#include <pcl/Math.h>
#include <pcl/Utility.h>
namespace pcl
{
#define m_width this->m_width
#define m_height this->m_height
#define m_fillBorder this->m_fillBorder
#define m_fillValue this->m_fillValue
#define m_data this->m_data
// ----------------------------------------------------------------------------
/*!
* \class BicubicInterpolationBase
* \brief Base class for bicubic interpolation algorithm implementations
*
* %BicubicInterpolationBase is a base class for BicubicSplineInterpolation and
* BicubicBSplineInterpolation.
*
* \sa BicubicSplineInterpolation, BicubicBSplineInterpolation
*/
template <typename T>
class PCL_CLASS BicubicInterpolationBase : public BidimensionalInterpolation<T>
{
public:
/*!
* Constructs a new %BicubicInterpolationBase instance.
*/
BicubicInterpolationBase() = default;
/*!
* Copy constructor.
*/
BicubicInterpolationBase( const BicubicInterpolationBase& ) = default;
protected:
void InitXY( int& i1, int& j1, double* p0, double* p1, double* p2, double* p3, double x, double y ) const noexcept
{
PCL_PRECONDITION( int( x ) >= 0 )
PCL_PRECONDITION( int( x ) < m_width )
PCL_PRECONDITION( int( y ) >= 0 )
PCL_PRECONDITION( int( y ) < m_height )
// Central grid coordinates
i1 = pcl::Range( TruncInt( y ), 0, m_height-1 );
j1 = pcl::Range( TruncInt( x ), 0, m_width-1 );
// Set up source matrix
int j0 = j1 - 1;
int i0 = i1 - 1;
int j2 = j1 + 1;
int i2 = i1 + 1;
int j3 = j1 + 2;
int i3 = i1 + 2;
const T* fp = m_data + (int64( i0 )*m_width + j0);
// Row 0
if ( i0 < 0 )
{
fp += m_width;
if ( m_fillBorder )
{
p0[0] = p0[1] = p0[2] = p0[3] = m_fillValue;
goto __row1;
}
}
GetRow( p0, fp, j0, j2, j3 );
if ( i0 >= 0 )
fp += m_width;
__row1: // Row 1
GetRow( p1, fp, j0, j2, j3 );
// Row 2
if ( i2 < m_height )
fp += m_width;
GetRow( p2, fp, j0, j2, j3 );
// Row 3
if ( i3 < m_height )
fp += m_width;
else if ( m_fillBorder )
{
p3[0] = p3[1] = p3[2] = p3[3] = m_fillValue;
goto __done;
}
GetRow( p3, fp, j0, j2, j3 );
__done:
;
}
void InitYX( int& i1, int& j1, double* p0, double* p1, double* p2, double* p3, double x, double y ) const noexcept
{
PCL_PRECONDITION( int( x ) >= 0 )
PCL_PRECONDITION( int( x ) < m_width )
PCL_PRECONDITION( int( y ) >= 0 )
PCL_PRECONDITION( int( y ) < m_height )
// Central grid coordinates
i1 = pcl::Range( TruncInt( y ), 0, m_height-1 );
j1 = pcl::Range( TruncInt( x ), 0, m_width-1 );
// Set up source matrix
int j0 = j1 - 1;
int i0 = i1 - 1;
int j2 = j1 + 1;
int i2 = i1 + 1;
int j3 = j1 + 2;
int i3 = i1 + 2;
const T* fp = m_data + (int64( i0 )*m_width + j0);
// Column 0
if ( j0 < 0 )
{
++fp;
if ( m_fillBorder )
{
p0[0] = p0[1] = p0[2] = p0[3] = m_fillValue;
goto __col1;
}
}
GetColumn( p0, fp, i0, i2, i3 );
if ( j0 >= 0 )
++fp;
__col1: // Column 1
GetColumn( p1, fp, i0, i2, i3 );
// Column 2
if ( j2 < m_width )
++fp;
GetColumn( p2, fp, i0, i2, i3 );
// Column 3
if ( j3 < m_width )
++fp;
else if ( m_fillBorder )
{
p3[0] = p3[1] = p3[2] = p3[3] = m_fillValue;
goto __done;
}
GetColumn( p3, fp, i0, i2, i3 );
__done:
;
}
private:
void GetRow( double* p, const T* fp, int j0, int j2, int j3 ) const noexcept
{
if ( m_fillBorder )
{
*p = (j0 >= 0) ? *fp : m_fillValue;
*++p = *++fp;
if ( j2 < m_width )
{
*++p = *++fp;
*++p = (j3 < m_width) ? *++fp : m_fillValue;
}
else
p[1] = p[2] = m_fillValue;
}
else
{
if ( j0 < 0 )
++fp;
*p = *fp;
if ( j0 >= 0 )
++fp;
*++p = *fp;
if ( j2 < m_width )
{
*++p = *++fp;
if ( j3 < m_width )
++fp;
*++p = *fp;
}
else
{
*++p = *fp;
*++p = *(fp - 1);
}
}
}
void GetColumn( double* p, const T* fp, int i0, int i2, int i3 ) const noexcept
{
if ( m_fillBorder )
{
*p = (i0 >= 0) ? *fp : m_fillValue;
*++p = *(fp += m_width);
if ( i2 < m_height )
{
*++p = *(fp += m_width);
*++p = (i3 < m_height) ? *(fp += m_width) : m_fillValue;
}
else
p[1] = p[2] = m_fillValue;
}
else
{
if ( i0 < 0 )
fp += m_width;
*p = *fp;
if ( i0 >= 0 )
fp += m_width;
*++p = *fp;
if ( i2 < m_height )
{
*++p = *(fp += m_width);
if ( i3 < m_height )
fp += m_width;
*++p = *fp;
}
else
{
*++p = *fp;
*++p = *(fp - m_width);
}
}
}
};
// ----------------------------------------------------------------------------
#define InitXY this->InitXY
#define InitYX this->InitYX
/*
* Undefine the following to use any free constant value a != -1/2
*/
#define __PCL_BICUBIC_SPLINE_A_IS_MINUS_ONE_HALF 1
/*
* The "a" constant controls the depth of the negative lobes in the bicubic
* spline interpolation function, -1 <= a < 0. Larger values of a (in absolute
* value) lead to more ringing (sharpness). The default is -1/2, as recommended
* in [Keys 1981].
*/
#define __PCL_BICUBIC_SPLINE_A -0.5
/*
* Default clamping threshold for linear images. This value has been optimized
* for a = -1/2. If you use another value for a, this must also be fine tuned.
*/
#ifndef __PCL_BICUBIC_SPLINE_CLAMPING_THRESHOLD
#define __PCL_BICUBIC_SPLINE_CLAMPING_THRESHOLD 0.3F
#endif
/*!
* \class BicubicSplineInterpolation
* \brief Bicubic spline interpolation algorithm
*
* Bicubic interpolation algorithms interpolate from the nearest sixteen mapped
* source data items. Our implementation uses the following cubic spline
* function as a separable filter to perform a convolution interpolation:
*
* <pre>
* f(x) = (a+2)*x^3 - (a+3)*x^2 + 1 for 0 <= x <= 1
* f(x) = a*x^3 - 5*a*x^2 + 8*a*x - 4*a for 1 < x <= 2
* f(x) = 0 otherwise
* </pre>
*
* Reference: Keys, R. G. (1981), <em>%Cubic %Convolution %Interpolation for
* %Digital %Image %Processing</em>, IEEE Trans. %Acoustics, %Speech & %Signal
* Proc., Vol. 29, pp. 1153-1160.
*
* The a constant parameter of the cubic spline (-1 <= a < 0) controls the
* depth of the negative lobes of the interpolation function. In this
* implementation we have set a fixed value <em>a</em>=-1/2.
*
* Our implementation includes an automatic <em>linear clamping</em> mechanism
* to avoid discontinuity problems when interpolating linear images. The cubic
* spline function has negative lobes that can cause undershoot (aka ringing)
* artifacts when they fall over bright pixels. This happens frequently with
* linear CCD images. See the documentation for the
* BicubicSplineInterpolation::SetClampingThreshold( float ) function for a
* more detailed description of the linear clamping mechanism.
*/
template <typename T>
class PCL_CLASS BicubicSplineInterpolation : public BicubicInterpolationBase<T>
{
public:
/*!
* Constructs a %BicubicSplineInterpolation instance.
*
* The optional \e clamp parameter defines a threshold to trigger the
* <em>linear clamping</em> mechanism. See the documentation for the
* SetClampingThreshold( float ) function for a detailed description of the
* automatic linear clamping mechanism. The default value of \e clamp = 0.1
* is appropriate for most linear images.
*/
BicubicSplineInterpolation( float clamp = __PCL_BICUBIC_SPLINE_CLAMPING_THRESHOLD )
: m_clamp( Range( clamp, 0.0F, 1.0F ) )
{
PCL_PRECONDITION( 0 <= clamp && clamp <= 1 )
}
/*!
* Copy constructor.
*/
BicubicSplineInterpolation( const BicubicSplineInterpolation& ) = default;
/*!
* Virtual destructor.
*/
virtual ~BicubicSplineInterpolation()
{
}
/*!
* Returns an interpolated value at {\a x,\a y} location.
*
* \param x,y %Coordinates of the interpolation point (horizontal,
* vertical).
*
* This function performs a two-dimensional interpolation via a convolution
* with the separable cubic spline filter.
*/
double operator()( double x, double y ) const override
{
PCL_PRECONDITION( m_data != nullptr )
PCL_PRECONDITION( m_width > 0 && m_height > 0 )
// Initialize grid coordinates and source matrix
int i1, j1;
double p0[ 4 ], p1[ 4 ], p2[ 4 ], p3[ 4 ];
InitXY( i1, j1, p0, p1, p2, p3, x, y );
// Cubic spline coefficients
double C[ 4 ];
GetSplineCoefficients( C, x-j1 );
// Interpolate neighbor rows
double c[ 4 ];
c[0] = Interpolate( p0, C );
c[1] = Interpolate( p1, C );
c[2] = Interpolate( p2, C );
c[3] = Interpolate( p3, C );
// Interpolate result vertically
GetSplineCoefficients( C, y-i1 );
return Interpolate( c, C );
}
/*!
* Horizontal interpolation.
*
* \param x,y %Coordinates of the interpolation point (horizontal,
* vertical).
*
* \param[out] fx Address of the first element of a vector where the four
* interpolated X-values will be stored.
*
* This function interpolates horizontally the four neighbor rows for the
* specified \a x, \a y coordinates. This is useful when this interpolation
* algorithm is being used to interpolate an image on the horizontal axis
* exclusively.
*/
void InterpolateX( double fx[], double x, double y ) const noexcept
{
PCL_PRECONDITION( m_data != nullptr )
PCL_PRECONDITION( m_width > 0 && m_height > 0 )
// Initialize grid coordinates and source matrix
int i1, j1;
double p0[ 4 ], p1[ 4 ], p2[ 4 ], p3[ 4 ];
InitXY( i1, j1, p0, p1, p2, p3, x, y );
// Cubic spline coefficients
double C[ 4 ];
GetSplineCoefficients( C, x-j1 );
// Interpolate neighbor rows
fx[0] = Interpolate( p0, C );
fx[1] = Interpolate( p1, C );
fx[2] = Interpolate( p2, C );
fx[3] = Interpolate( p3, C );
}
/*!
* Vertical interpolation.
*
* \param x,y %Coordinates of the interpolation point (horizontal,
* vertical).
*
* \param[out] fy Address of the first element of a vector where the four
* interpolated Y-values will be stored.
*
* This function interpolates vertically the four neighbor columns for the
* specified \a x, \a y coordinates. This is useful when this interpolation
* algorithm is being used to interpolate an image on the vertical axis
* exclusively.
*/
void InterpolateY( double fy[], double x, double y ) const noexcept
{
PCL_PRECONDITION( m_data != nullptr )
PCL_PRECONDITION( m_width > 0 && m_height > 0 )
// Initialize grid coordinates and source matrix
int i1, j1;
double p0[ 4 ], p1[ 4 ], p2[ 4 ], p3[ 4 ];
InitYX( i1, j1, p0, p1, p2, p3, x, y );
// Cubic spline coefficients
double C[ 4 ];
GetSplineCoefficients( C, y-i1 );
// Interpolate neighbor columns
fy[0] = Interpolate( p0, C );
fy[1] = Interpolate( p1, C );
fy[2] = Interpolate( p2, C );
fy[3] = Interpolate( p3, C );
}
/*!
* %Vector interpolation.
*
* \param c Address of the first element of a vector of four data points.
*
* \param dx %Interpolation point in the range [0,+1[. A value of zero
* corresponds to the second element in the f vector.
*
* This function interpolates four neighbor rows or columns by direct
* convolution with the cubic spline function. The four elements of the \a c
* vector can be raw data points, to use cubic spline interpolation in one
* dimension, or they can be interpolated rows or columns from an arbitrary
* 2-D matrix. For example, \a c can be generated by a previous call to
* InterpolateX() or InterpolateY(), respectively to provide source
* interpolated rows or columns, or by equivalent functions from a different
* separable cubic interpolation algorithm. This is useful to mix cubic
* spline interpolation with other interpolation algorithms, which allows
* for flexible interpolation schemes.
*/
double InterpolateVector( const double c[], double dx ) const noexcept
{
double C[ 4 ];
GetSplineCoefficients( C, dx );
return Interpolate( c, C );
}
/*!
* Returns the current <em>linear clamping threshold</em> for this
* interpolation object.
*
* See the documentation for SetClampingThreshold( float ) for a detailed
* description of the automatic linear clamping mechanism.
*/
float ClampingThreshold() const noexcept
{
return m_clamp;
}
/*!
* Defines a threshold to trigger the <em>linear clamping</em> mechanism.
* The clamping mechanism automatically switches to linear interpolation
* when the differences between neighbor pixels are so large that the cubic
* interpolation function may cause ringing artifacts. Ringing occurs when
* the negative lobes of the cubic spline interpolation function fall over
* isolated bright source pixels or bright edges. For example, ringing
* problems happen frequently around stars in linear CCD images. For
* nonlinear images, linear clamping is almost never necessary, as in
* nonlinear images (e.g., stretched deep-sky images, or diurnal images)
* there are normally no such large variations between neighbor pixels.
*
* Linear clamping works on a per-row or per-column basis within the
* interpolation neighborhood of 16 pixels. This means that when the
* clamping mechanism selects linear interpolation, it restricts its use to
* the affected (by too strong variations) row or column, without changing
* the bicubic interpolation scheme as a whole. This ensures artifact-free
* interpolated images without degrading the overall performance of bicubic
* spline interpolation.
*
* The specified clamping threshold \e clamp must be in the [0,1] range.
* Lower values cause a more aggressive deringing effect.
*/
void SetClampingThreshold( float c ) noexcept
{
PCL_PRECONDITION( 0 <= c && c <= 1 )
m_clamp = Range( c, 0.0F, 1.0F );
}
private:
double m_clamp;
PCL_HOT_FUNCTION
double Interpolate( const double* __restrict__ p, const double* __restrict__ C ) const noexcept
{
// Unclamped code:
//return p[0]*C[0] + p[1]*C[1] + p[2]*C[2] + p[3]*C[3];
double f12 = p[1]*C[1] + p[2]*C[2];
double f03 = p[0]*C[0] + p[3]*C[3];
return (-f03 < f12*m_clamp) ? f12 + f03 : f12/(C[1] + C[2]);
}
PCL_HOT_FUNCTION
void GetSplineCoefficients( double* __restrict__ C, double dx ) const noexcept
{
double dx2 = dx*dx;
double dx3 = dx2*dx;
#ifdef __PCL_BICUBIC_SPLINE_A_IS_MINUS_ONE_HALF
// Optimized code for a = -1/2
// We *really* need optimization here since this routine is called twice
// for each interpolated pixel.
double dx1_2 = dx/2;
double dx2_2 = dx2/2;
double dx3_2 = dx3/2;
double dx22 = dx2 + dx2;
double dx315 = dx3 + dx3_2;
C[0] = dx2 - dx3_2 - dx1_2;
C[1] = dx315 - dx22 - dx2_2 + 1;
C[2] = dx22 - dx315 + dx1_2;
C[3] = dx3_2 - dx2_2;
#else
# define a (__PCL_BICUBIC_SPLINE_A)
C[0] = a*dx3 - 2*a*dx2 + a*dx;
C[1] = (a + 2)*dx3 - (a + 3)*dx2 + 1;
C[2] = -(a + 2)*dx3 + (2*a + 3)*dx2 - a*dx;
C[3] = -a*dx3 + a*dx2;
# undef a
#endif
}
};
/*!
* \class BicubicInterpolation
* \brief Bicubic interpolation - an alias for BicubicSplineInterpolation
*
* %BicubicInterpolation is a synonym for the BicubicSplineInterpolation class.
*
* \deprecated This class exists to support old PCL-based code; all new code
* should use the BicubicSplineInterpolation class.
*
* \sa BicubicSplineInterpolation
*/
template <typename T>
class PCL_CLASS BicubicInterpolation : public BicubicSplineInterpolation<T>
{
public:
/*!
* Constructs a %BicubicInterpolation instance.
*/
BicubicInterpolation() = default;
/*!
* Copy constructor.
*/
BicubicInterpolation( const BicubicInterpolation& ) = default;
/*!
* Virtual destructor.
*/
virtual ~BicubicInterpolation()
{
}
};
// ----------------------------------------------------------------------------
/*!
* \class BicubicBSplineInterpolation
* \brief Bicubic B-Spline Interpolation Algorithm
*
* Like bicubic spline interpolation, the bicubic B-spline interpolation
* algorithm also interpolates from the nearest sixteen data items. However,
* this algorithm uses B-spline interpolating functions instead of cubic
* splines, which yields quite (too?) smooth results.
*
* This implementation is based on <em>Bicubic %Interpolation for %Image
* Scaling</em>, by Paul Bourke. It performs a convolution with a nonseparable
* 2-D filter, so its performance is O(n^2).
*
* \sa BicubicSplineInterpolation, BicubicInterpolation, BilinearInterpolation,
* NearestNeighborInterpolation
*/
template <typename T>
class PCL_CLASS BicubicBSplineInterpolation : public BicubicInterpolationBase<T>
{
public:
/*!
* Constructs a %BicubicBSplineInterpolation instance.
*/
BicubicBSplineInterpolation() = default;
/*!
* Copy constructor.
*/
BicubicBSplineInterpolation( const BicubicBSplineInterpolation& ) = default;
/*!
* Virtual destructor.
*/
virtual ~BicubicBSplineInterpolation()
{
}
/*!
* Interpolated value at \a {x,y} location.
*
* \param x,y %Coordinates of the interpolation point (horizontal,
* vertical).
*/
double operator()( double x, double y ) const override
{
PCL_PRECONDITION( f != 0 )
PCL_PRECONDITION( m_width > 0 && m_height > 0 )
// Initialize grid coordinates and source matrix
int i1, j1;
double p0[ 4 ], p1[ 4 ], p2[ 4 ], p3[ 4 ];
InitXY( i1, j1, p0, p1, p2, p3, x, y );
// Bicubic B-Spline interpolation functions
double dx = x - j1;
double dx0 = -1 - dx;
double dx1 = -dx;
double dx2 = 1 - dx;
double dx3 = 2 - dx;
double dy = y - i1;
double dy0 = -1 - dy;
double dy1 = -dy;
double dy2 = 1 - dy;
double dy3 = 2 - dy;
return
BXY( p0, 0, dx0, dy0 ) +
BXY( p0, 1, dx1, dy0 ) +
BXY( p0, 2, dx2, dy0 ) +
BXY( p0, 3, dx3, dy0 ) +
BXY( p1, 0, dx0, dy1 ) +
BXY( p1, 1, dx1, dy1 ) +
BXY( p1, 2, dx2, dy1 ) +
BXY( p1, 3, dx3, dy1 ) +
BXY( p2, 0, dx0, dy2 ) +
BXY( p2, 1, dx1, dy2 ) +
BXY( p2, 2, dx2, dy2 ) +
BXY( p2, 3, dx3, dy2 ) +
BXY( p3, 0, dx0, dy3 ) +
BXY( p3, 1, dx1, dy3 ) +
BXY( p3, 2, dx2, dy3 ) +
BXY( p3, 3, dx3, dy3 );
}
private:
double BXY( const double* __restrict__ p, int j, double x, double y ) const noexcept
{
return p[j]*B( x )*B( y );
}
double B( double x ) const noexcept
{
double fx = (x > 0) ? x*x*x : 0;
double fxp1 = x + 1;
fxp1 = (fxp1 > 0) ? fxp1*fxp1*fxp1 : 0;
double fxp2 = x + 2;
fxp2 = (fxp2 > 0) ? fxp2*fxp2*fxp2 : 0;
double fxm1 = x - 1;
fxm1 = (fxm1 > 0) ? fxm1*fxm1*fxm1 : 0;
return (fxp2 - 4*fxp1 + 6*fx - 4*fxm1)/6;
}
};
// ----------------------------------------------------------------------------
#undef InitXY
#undef InitYX
// ----------------------------------------------------------------------------
#undef m_width
#undef m_height
#undef m_fillBorder
#undef m_fillValue
#undef m_data
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BicubicInterpolation_h
// ----------------------------------------------------------------------------
// EOF pcl/BicubicInterpolation.h - Released 2022-03-12T18:59:29Z
-236
View File
@@ -1,236 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/BidimensionalInterpolation.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_BidimensionalInterpolation_h
#define __PCL_BidimensionalInterpolation_h
/// \file pcl/BidimensionalInterpolation.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/Exception.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class BidimensionalInterpolation
* \brief A generic interface to two-dimensional interpolation algorithms.
*
* %BidimensionalInterpolation is a base class for all two-dimensional
* interpolation algorithm implementations in PCL.
*/
template <typename T>
class PCL_CLASS BidimensionalInterpolation
{
public:
/*!
* Constructs a %BidimensionalInterpolation object.
*/
BidimensionalInterpolation() = default;
/*!
* Copy constructor.
*/
BidimensionalInterpolation( const BidimensionalInterpolation& ) = default;
/*!
* Destroys a %BidimensionalInterpolation object.
*/
virtual ~BidimensionalInterpolation()
{
Clear();
}
/*!
* Initializes a new interpolation.
*
* \param data Two-dimensional matrix of function values stored in
* row-order. Must remain valid and accessible while this
* object is used to compute interpolated function values.
*
* \param width Horizontal dimension (most rapidly varying coordinate) of
* the data array.
*
* \param height Vertical dimension (most slowly varying coordinate) of the
* data array.
*/
virtual void Initialize( const T* data, int width, int height )
{
if ( data == nullptr )
throw Error( "Null data pointer in BidimensionalInterpolation::Initialize()" );
if ( width <= 0 || height <= 0 )
throw Error( "Invalid dimensions in BidimensionalInterpolation::Initialize()" );
m_data = data;
m_width = width;
m_height = height;
}
/*!
* Returns an interpolated function value at \a x, \a y coordinates.
*/
virtual double operator()( double x, double y ) const = 0;
/*!
* Clears auxiliary/intermediate data (and/or whatever requires clean up).
* Derived classes overriding this function should call their base class
* version via explicit downcast.
*/
virtual void Clear()
{
m_data = nullptr;
m_width = m_height = 0;
}
/*!
* Returns a pointer to the interpolated data array.
*/
const T* BeingInterpolated() const
{
return m_data;
}
/*!
* Returns the width (number of columns) of the interpolated data matrix.
*/
int Width() const
{
return m_width;
}
/*!
* Returns the height (number of rows) of the interpolated data matrix.
*/
int Height() const
{
return m_height;
}
/*!
* Enables (or disables) border filling.
*
* When border filling is enabled, a user-defined constant fill value is
* used to interpolate at locations near the borders of the data matrix.
*
* When border filling is disabled, existing border values are extended to
* interpolate at border locations (Neumann boundary conditions).
*/
void EnableBorderFilling( bool enable = true )
{
m_fillBorder = enable;
}
/*!
* Disables (or enables) border filling.
*
* This is a convenience member function, equivalent to:
*
* EnableBorderFilling( !disable );
*/
void DisableBorderFilling( bool disable = true )
{
m_fillBorder = !disable;
}
/*!
* Returns true iff border filling is enabled for this interpolation. See the
* documentation for EnableBorderFilling() for more information.
*/
bool IsBorderFillingEnabled() const
{
return m_fillBorder;
}
/*!
* Sets the border fill value \a v. See the documentation for
* EnableBorderFilling() for more information about border filling and
* boundary conditions.
*
* \param v Border fill value. It is the responsibility of the caller to
* ensure that the specified value is within the valid range of
* the data type used by this interpolation.
*/
void SetBorderFillValue( double v )
{
m_fillValue = v;
}
/*!
* Returns the current border fill value for this interpolation. See the
* documentation for EnableBorderFilling() for more information about border
* filling and boundary conditions.
*/
double BorderFillValue() const
{
return m_fillValue;
}
protected:
const T* m_data = nullptr; // functional data being interpolated
int m_width = 0; // width of the data table
int m_height = 0; // height of the data table
double m_fillValue = 0; // fill value, when m_fillBorder = true
bool m_fillBorder = false; // don't apply Neumann boundary conditions
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BidimensionalInterpolation_h
// ----------------------------------------------------------------------------
// EOF pcl/BidimensionalInterpolation.h - Released 2022-03-12T18:59:29Z
-164
View File
@@ -1,164 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/BilinearInterpolation.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_BilinearInterpolation_h
#define __PCL_BilinearInterpolation_h
/// \file pcl/BilinearInterpolation.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/BidimensionalInterpolation.h>
#include <pcl/Utility.h>
namespace pcl
{
// ----------------------------------------------------------------------------
#define m_width this->m_width
#define m_height this->m_height
#define m_fillBorder this->m_fillBorder
#define m_fillValue this->m_fillValue
#define m_data this->m_data
// ----------------------------------------------------------------------------
/*!
* \class BilinearInterpolation
* \brief Bilinear interpolation algorithm.
*
* The bilinear interpolation algorithm interpolates from the nearest four
* mapped source data items. It builds and evaluates two linear interpolation
* polynomials, one for each plane direction.
*
* \sa NearestNeighborInterpolation, BicubicSplineInterpolation,
* BicubicBSplineInterpolation, BicubicFilterInterpolation,
*/
template <typename T>
class PCL_CLASS BilinearInterpolation : public BidimensionalInterpolation<T>
{
public:
/*!
* Constructs a %BilinearInterpolation instance.
*/
BilinearInterpolation() = default;
/*!
* Copy constructor.
*/
BilinearInterpolation( const BilinearInterpolation& ) = default;
/*!
* Virtual destructor.
*/
virtual ~BilinearInterpolation()
{
}
/*!
* Returns an interpolated value at {\a x,\a y} location.
*
* \param x,y Coordinates of the interpolation point (horizontal,vertical).
*/
double operator()( double x, double y ) const override
{
PCL_PRECONDITION( m_data != nullptr )
PCL_PRECONDITION( m_width > 0 && m_height > 0 )
int j0 = pcl::Range( TruncInt( x ), 0, m_width-1 );
int i0 = pcl::Range( TruncInt( y ), 0, m_height-1 );
int j1 = j0 + 1;
int i1 = i0 + 1;
double p00, p10, p01, p11;
const T* fp = m_data + (int64( i0 )*m_width + j0);
p00 = *fp;
p10 = (j1 < m_width) ? fp[1] : (m_fillBorder ? m_fillValue : *fp);
if ( i1 < m_height )
fp += m_width;
else if ( m_fillBorder )
{
p01 = p11 = m_fillValue;
goto __1;
}
p01 = *fp;
p11 = (j1 < m_width) ? fp[1] : (m_fillBorder ? m_fillValue : *fp);
__1:
double dx = x - j0, dx1 = 1 - dx;
double dy = y - i0, dy1 = 1 - dy;
return p00*dx1*dy1 + p10*dx*dy1 + p01*dx1*dy + p11*dx*dy;
}
};
// ----------------------------------------------------------------------------
#undef m_width
#undef m_height
#undef m_fillBorder
#undef m_fillValue
#undef m_data
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BilinearInterpolation_h
// ----------------------------------------------------------------------------
// EOF pcl/BilinearInterpolation.h - Released 2022-03-12T18:59:29Z
-1531
View File
File diff suppressed because it is too large Load Diff
-156
View File
@@ -1,156 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/BitmapBox.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_BitmapBox_h
#define __PCL_BitmapBox_h
/// \file pcl/BitmapBox.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/Bitmap.h>
#include <pcl/Frame.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class BitmapBox
* \brief Client-side interface to a PixInsight %BitmapBox control.
*
* ### TODO: Write a detailed description for %BitmapBox
*/
class PCL_CLASS BitmapBox : public Frame
{
public:
/*!
* Constructs a %BitmapBox control that draws a bitmap \a bmp and is a child
* of \a parent.
*/
BitmapBox( const Bitmap& bmp = Bitmap::Null(), Control& parent = Control::Null() );
/*!
* Destroys a %BitmapBox object.
*/
virtual ~BitmapBox()
{
}
/*!
* Returns the bitmap currently drawn by this %BitmapBox control.
*/
Bitmap CurrentBitmap() const;
/*!
* Sets the bitmap \a bmp for this %BitmapBox control.
*/
void SetBitmap( const Bitmap& bmp );
/*!
* Removes the bitmap in this %BitmapBox control. Does not destroy the
* bitmap (unless it becomes unreferenced); only disassociates it from this
* %BitmapBox control.
*/
void Clear()
{
SetBitmap( Bitmap::Null() );
}
/*!
* Returns the margin in pixels that this %BitmapBox control reserves around
* its bitmap.
*/
int Margin() const;
/*!
* Sets a new margin \a m in pixels for this %BitmapBox control.
*/
void SetMargin( int m );
/*!
* Sets the margin of this %BitmapBox control to zero pixels.
*/
void ClearMargin()
{
SetMargin( 0 );
}
/*! #
*/
bool IsAutoFitEnabled() const;
/*! #
*/
void EnableAutoFit( bool = true );
/*! #
*/
void DisableAutoFit( bool disable = true )
{
EnableAutoFit( !disable );
}
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
#endif // __PCL_BitmapBox_h
// ----------------------------------------------------------------------------
// EOF pcl/BitmapBox.h - Released 2022-03-12T18:59:29Z
-820
View File
@@ -1,820 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Brush.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Brush_h
#define __PCL_Brush_h
/// \file pcl/Brush.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/Color.h>
#include <pcl/Rectangle.h>
#include <pcl/UIObject.h>
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::BrushStyle
* \brief Supported brush styles.
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>BrushStyle::Empty</td> <td>Empty brush (transparent brush)</td></tr>
* <tr><td>BrushStyle::Solid</td> <td>Solid brush</td></tr>
* <tr><td>BrushStyle::Dense</td> <td>Dense pattern brush</td></tr>
* <tr><td>BrushStyle::HalfTone</td> <td>50% pattern brush</td></tr>
* <tr><td>BrushStyle::Sparse</td> <td>Sparse pattern brush</td></tr>
* <tr><td>BrushStyle::HorzizontalHatch</td> <td>-----</td></tr>
* <tr><td>BrushStyle::VerticalHatch</td> <td>|||||</td></tr>
* <tr><td>BrushStyle::CrossHatch</td> <td>+++++</td></tr>
* <tr><td>BrushStyle::ForwardDiagonalHatch</td> <td>/////</td></tr>
* <tr><td>BrushStyle::BackwardDiagonalHatch</td><td>\\\\\\\\\\ </td></tr>
* <tr><td>BrushStyle::CrossDiagonalHatch</td> <td>XXXXX</td></tr>
* <tr><td>BrushStyle::Stipple</td> <td>Fill with a tiled Bitmap</td></tr>
* <tr><td>BrushStyle::LinearGradient</td> <td>Fill with a linear gradient</td></tr>
* <tr><td>BrushStyle::RadialGradient</td> <td>Fill with a radial gradient</td></tr>
* <tr><td>BrushStyle::ConicalGradient</td> <td>Fill with a conical gradient</td></tr>
* </table>
*/
namespace BrushStyle
{
enum value_type
{
Empty, // empty brush (transparent brush)
Solid, // solid brush
Dense, // dense pattern brush
HalfTone, // 50% pattern brush
Sparse, // sparse pattern brush
HorzizontalHatch, // -----
VerticalHatch, // |||||
CrossHatch, // +++++
ForwardDiagonalHatch, // /////
BackwardDiagonalHatch, // \\\\\. <--- why this dot? :)
CrossDiagonalHatch, // XXXXX
Stipple, // fill with a tiled Bitmap
LinearGradient, // fill with a linear gradient
RadialGradient, // fill with a radial gradient
ConicalGradient, // fill with a conical gradient
NumberOfBrushStyles
};
}
/*!
* \namespace pcl::GradientSpreadMode
* \brief Supported gradient spread modes.
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>GradientSpreadMode::Pad</td> <td>Areas outside the gradient are filled with the nearest (first or last) stop color.</td></tr>
* <tr><td>GradientSpreadMode::Reflect</td> <td>Gradients are reflected outside gradient areas.</td></tr>
* <tr><td>GradientSpreadMode::Repeat</td> <td>Gradients are repeated outside gradient areas.</td></tr>
* </table>
*/
namespace GradientSpreadMode
{
enum value_type
{
Pad,
Reflect,
Repeat,
NumberOfGradientSpreadModes
};
}
// ----------------------------------------------------------------------------
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
class PCL_CLASS Bitmap;
// ----------------------------------------------------------------------------
/*!
* \class Brush
* \brief Client-side interface to a PixInsight %Brush object.
*
* ### TODO: Write a detailed description for %Brush.
*
* \sa GradientBrush, LinearGradientBrush, RadialGradientBrush,
* ConicalGradientBrush
*/
class PCL_CLASS Brush : public UIObject
{
public:
/*!
* Represents the brush style.
* Supported values are defined in the BrushStyle namespace.
*/
typedef BrushStyle::value_type style;
/*!
* Constructs a brush with the specified \a color and \a style.
*/
Brush( RGBA color = 0xff000000, style = BrushStyle::Solid );
/*!
* Constructs a stippled brush with the specified bitmap pattern \a bmp.
*/
Brush( const Bitmap& bmp );
/*!
* Copy constructor. This object will reference the same server-side brush
* as the specified instance \a b.
*/
Brush( const Brush& b ) : UIObject( b )
{
}
/*!
* Move constructor.
*/
Brush( Brush&& x ) : UIObject( std::move( x ) )
{
}
/*!
* Destroys a %Brush object. If this object references an existing brush in
* the PixInsight core application, its reference count is decremented. If
* it becomes unreferenced, it will be garbage-collected.
*/
virtual ~Brush()
{
}
/*!
* Copy assignment operator. Returns a reference to this object.
*
* Makes this object reference the same server-side brush as the specified
* instance \a b. If the previous brush becomes unreferenced, it will be
* garbage-collected by the PixInsight core application.
*/
Brush& operator =( const Brush& b )
{
Assign( b );
return *this;
}
/*!
* Move assignment operator. Returns a reference to this object.
*/
Brush& operator =( Brush&& x )
{
Transfer( x );
return *this;
}
/*!
* Returns a reference to a <em>null brush</em>. A null %Brush object does
* not correspond to an existing brush object in the PixInsight core
* application.
*/
static Brush& Null();
/*!
* Returns the current color of this brush.
*/
RGBA Color() const;
/*!
* Sets the color of this brush.
*/
void SetColor( RGBA );
/*!
* Returns the current style of this brush.
*/
style Style() const;
/*!
* Returns true iff this brush is solid, i.e. if its current style is
* BrushStyle::Solid.
*/
bool IsSolid() const
{
return Style() == BrushStyle::Solid;
}
/*!
* Returns true iff this brush is empty (or transparent), i.e. if its current
* style is BrushStyle::Empty. An empty brush produces transparent shapes.
*/
bool IsEmpty() const
{
return Style() == BrushStyle::Empty;
}
/*!
* Returns true iff this brush is transparent. This function is a synonym
* for IsEmpty().
*/
bool IsTransparent() const
{
return IsEmpty();
}
/*!
* Returns true iff this brush is \e stippled, i.e. if its current style is
* BrushStyle::Stippled. A stippled brush draws a regular pattern
* consisting of multiple, adjacent copies of a Bitmap image.
*/
bool IsStippled() const
{
return Style() == BrushStyle::Stipple;
}
/*!
* Sets the style of this brush.
*
* Gradient styles (BrushStyle::LinearGradient, BrushStyle::RadialGradient
* and BrushStyle::ConicalGradient) cannot be set with this function, since
* gradient brushes are implemented as separate PCL classes
* (LinearGradientBrush, RadialGradientBrush and ConicalGradientBrush,
* respectively).
*/
void SetStyle( style );
/*!
* Returns the current \e stipple of this brush. If the current style of
* this brush is not BrushStyle::Stippled, a null Bitmap object is
* returned.
*/
Bitmap Stipple() const;
/*!
* Sets the current \e stipple for this brush. This function implicitly
* forces the style of this brush to be BrushStyle::Stippled.
*/
void SetStipple( const Bitmap& );
/*!
* Returns true iff this object is a gradient brush.
*/
virtual bool IsGradient() const
{
return false;
}
private:
Brush( void* h ) : UIObject( h )
{
}
void* CloneHandle() const override;
friend class GraphicsContextBase;
friend class Graphics;
friend class VectorGraphics;
friend class GradientBrush;
friend class Pen;
};
// ----------------------------------------------------------------------------
/*!
* \class GradientBrush
* \brief Base class of PCL gradient brushes.
*
* ### TODO: Write a detailed description for %GradientBrush.
*
* \sa Brush, LinearGradientBrush, RadialGradientBrush, ConicalGradientBrush
*/
class PCL_CLASS GradientBrush : public Brush
{
public:
/*!
* Represents a gradient spread mode.
* Supported values are defined in the GradientSpreadMode namespace.
*/
typedef GradientSpreadMode::value_type spread_mode;
/*! \struct Stop
* \brief Gradient stop.
*
* A gradient brush interpolates color values from an ordered list of
* <em>gradient stops</em>. A gradient stop is formed by a position in the
* [0,1] range and a RGBA color value.
*/
struct Stop
{
double position = 0; //!< Stop position in the [0,1] range, where 0 and 1 correspond, respectively, to the starting and end locations of the gradient area.
RGBA color = 0xff000000; //!< Stop color encoded as a 32-bit AARRGGBB value.
/*!
* Constructs a default gradient stop.
*/
Stop() = default;
/*!
* Constructs a gradient stop at the specified position \a p with the
* color \a c.
*/
Stop( double p, RGBA c )
: position( Range( p, 0.0, 1.0 ) )
, color( c )
{
}
/*!
* Copy constructor.
*/
Stop( const Stop& ) = default;
/*!
* Equality operator. Used to enforce ordering of gradient stop lists.
*/
bool operator ==( const Stop& x ) const
{
return position == x.position && color == x.color;
}
/*!
* Less than relational operator. Used to enforce ordering of gradient
* stop lists.
*
* Gradient stop comparison is exclusively based on stop positions; stop
* colors are irrelevant for ordering.
*/
bool operator <( const Stop& x ) const
{
return position < x.position; // color is irrelevant to ordering of gradient stops
}
};
/*!
* Represents a list of gradient stops.
*/
typedef Array<Stop> stop_list;
/*!
* Returns the list of stops in this gradient brush.
*/
stop_list Stops() const;
/*!
* Returns the current gradient spread mode for this gradient brush.
*/
spread_mode SpreadMode() const;
/*!
*/
bool IsGradient() const override
{
return true;
}
protected:
GradientBrush( void* h ) : Brush( h )
{
}
GradientBrush( const GradientBrush& x ) : Brush( x )
{
}
GradientBrush( GradientBrush&& x ) : Brush( std::move( x ) )
{
}
};
/*!
* \class LinearGradientBrush
* \brief Linear gradient brush.
*
* ### TODO: Write a detailed description for %LinearGradientBrush.
*
* \sa Brush, GradientBrush, RadialGradientBrush, ConicalGradientBrush
*/
class PCL_CLASS LinearGradientBrush : public GradientBrush
{
public:
/*!
* Represents a gradient spread mode.
* Supported values are defined in the GradientSpreadMode namespace.
*/
typedef GradientBrush::spread_mode spread_mode;
/*!
* Represents a list of gradient stops.
*/
typedef GradientBrush::stop_list stop_list;
/*!
* Constructs a %LinearGradientBrush object.
*
* \param x1,y1 Coordinates of the gradient's starting point.
*
* \param x2,y2 Coordinates of the gradient's end point.
*
* \param stops Reference to a list of gradient stops. If an empty list is
* specified (as by default), two stops will be generated
* automatically: {0.0,0x00000000} and {1.0,0xFF000000}.
*
* \param spread Gradient spread mode. Supported spread modes are defined
* in the GradientSpreadMode namespace. The default is
* GradientSpreadMode::Pad.
*/
LinearGradientBrush( double x1, double y1, double x2, double y2,
const stop_list& stops = stop_list(),
spread_mode spread = GradientSpreadMode::Pad );
/*!
* Constructs a %LinearGradientBrush object.
*
* This is an overloaded constructor, provided for convenience. It behaves
* like the preceding constructor, except the linear gradient parameters are
* specified as a rectangle \a r using floating point coordinates.
*/
LinearGradientBrush( const DRect& r,
const stop_list& stops = stop_list(),
spread_mode spread = GradientSpreadMode::Pad );
/*!
* Constructs a %LinearGradientBrush object.
*
* This is an overloaded constructor, provided for convenience. It behaves
* like the preceding constructor, except the linear gradient parameters are
* specified as a rectangle \a r using integer coordinates.
*/
LinearGradientBrush( const Rect& r,
const stop_list& stops = stop_list(),
spread_mode spread = GradientSpreadMode::Pad );
/*!
* Copy constructor. This object will reference the same server-side brush
* as the specified instance \a b.
*/
LinearGradientBrush( const LinearGradientBrush& b )
: GradientBrush( b )
{
}
/*!
* Move constructor.
*/
LinearGradientBrush( LinearGradientBrush&& x )
: GradientBrush( std::move( x ) )
{
}
/*!
* Copy assignment operator. Returns a reference to this object.
*
* Makes this object reference the same server-side brush as the specified
* instance \a b. If the previous brush becomes unreferenced, it will be
* garbage-collected by the PixInsight core application.
*/
LinearGradientBrush& operator =( const LinearGradientBrush& b )
{
SetHandle( b.handle );
return *this;
}
/*!
* Move assignment operator. Returns a reference to this object.
*/
LinearGradientBrush& operator =( LinearGradientBrush&& x )
{
Transfer( x );
return *this;
}
/*!
* Retrieves the linear gradient parameters of this object.
*
* \param[out] x1,y1 Coordinates of the gradient's starting point.
* \param[out] x2,y2 Coordinates of the gradient's end point.
*
* \sa Parameters()
*/
void GetParameters( double& x1, double& y1, double& x2, double& y2 ) const;
/*!
* Returns the linear gradient parameters of this object as a DRect
* object.
*
* \sa GetParameters( double&, double&, double&, double& )
*/
DRect Parameters() const
{
DRect r;
GetParameters( r.x0, r.y0, r.x1, r.y1 );
return r;
}
};
/*!
* \class RadialGradientBrush
* \brief Radial gradient brush.
*
* ### TODO: Write a detailed description for %RadialGradientBrush.
*
* \sa Brush, GradientBrush, LinearGradientBrush, ConicalGradientBrush
*/
class PCL_CLASS RadialGradientBrush : public GradientBrush
{
public:
/*!
* Represents a gradient spread mode.
* Supported values are defined in the GradientSpreadMode namespace.
*/
typedef GradientBrush::spread_mode spread_mode;
/*!
* Represents a list of gradient stops.
*/
typedef GradientBrush::stop_list stop_list;
/*!
* Constructs a %RadialGradientBrush object.
*
* \param cx,cy Coordinates of the gradient's center.
*
* \param r Gradient's radius.
*
* \param fx,fy Coordinates of the gradient's focal point. If these
* coordinates are not specified, they will be set at
* the specified gradient's center point.
*
* \param stops Reference to a list of gradient stops. If an empty list is
* specified (as by default), two stops will be generated
* automatically: {0.0,0x00000000} and {1.0,0xFF000000}.
*
* \param spread Gradient spread mode. Supported spread modes are defined
* in the GradientSpreadMode namespace. The default is
* GradientSpreadMode::Pad.
*/
RadialGradientBrush( double cx, double cy, double r, double fx = uint32_max, double fy = uint32_max,
const stop_list& stops = stop_list(),
spread_mode spread = GradientSpreadMode::Pad );
/*!
* Constructs a %RadialGradientBrush object.
*
* This is an overloaded constructor, provided for convenience. It behaves
* like the preceding constructor, except the radial gradient parameters are
* specified as a center point \a c, radius \a r and focal point \a f.
*/
RadialGradientBrush( const DPoint& c, double r, const DPoint& f = DPoint( uint32_max ),
const stop_list& stops = stop_list(),
spread_mode spread = GradientSpreadMode::Pad );
/*!
* Constructs a %RadialGradientBrush object.
*
* This is an overloaded constructor, provided for convenience. It behaves
* like the preceding constructor, except the radial gradient parameters are
* specified as a center point \a c, radius \a r and focal point \a f.
*/
RadialGradientBrush( const Point& c, double r, const Point& f = Point( uint32_max ),
const stop_list& stops = stop_list(),
spread_mode spread = GradientSpreadMode::Pad );
/*!
* Copy constructor. This object will reference the same server-side brush
* as the specified instance \a b.
*/
RadialGradientBrush( const RadialGradientBrush& b )
: GradientBrush( b )
{
}
/*!
* Move constructor.
*/
RadialGradientBrush( RadialGradientBrush&& x )
: GradientBrush( std::move( x ) )
{
}
/*!
* Copy assignment operator. Returns a reference to this object.
*
* Makes this object reference the same server-side brush as the specified
* instance \a b. If the previous brush becomes unreferenced, it will be
* garbage-collected by the PixInsight core application.
*/
RadialGradientBrush& operator =( const RadialGradientBrush& b )
{
SetHandle( b.handle );
return *this;
}
/*!
* Move assignment operator. Returns a reference to this object.
*/
RadialGradientBrush& operator =( RadialGradientBrush&& x )
{
Transfer( x );
return *this;
}
/*!
* Retrieves the radial gradient parameters of this object.
*
* \param[out] cx,cy Coordinates of the gradient's center.
* \param[out] r Gradient's radius.
* \param[out] fx,fy Coordinates of the gradient's focal point.
*
* \sa GetParameters( DPoint&, double&, DPoint& )
*/
void GetParameters( double& cx, double& cy, double& r, double& fx, double& fy ) const;
/*!
* Returns the radial gradient parameters of this object.
*
* This is an overloaded function, provided for convenience. It behaves like
* the preceding function, except the center and focal point parameters are
* retrieved as DPoint objects.
*
* \sa GetParameters( double&, double&, double&, double&, double& )
*/
void GetParameters( DPoint& c, double& r, DPoint& f ) const
{
GetParameters( c.x, c.y, r, f.x, f.y );
}
};
/*!
* \class ConicalGradientBrush
* \brief Conical gradient brush.
*
* ### TODO: Write a detailed description for %ConicalGradientBrush.
*
* \sa Brush, GradientBrush, LinearGradientBrush, RadialGradientBrush
*/
class PCL_CLASS ConicalGradientBrush : public GradientBrush
{
public:
/*!
* Represents a list of gradient stops.
*/
typedef GradientBrush::stop_list stop_list;
/*!
* Constructs a %ConicalGradientBrush object.
*
* \param cx,cy Coordinates of the gradient's center.
*
* \param a Gradient's angle in radians.
*
* \param stops Reference to a list of gradient stops. If an empty list is
* specified (as by default), two stops will be generated
* automatically: {0.0,0x00000000} and {1.0,0xFF000000}.
*/
ConicalGradientBrush( double cx, double cy, double a, const stop_list& stops = stop_list() );
/*!
* Constructs a %ConicalGradientBrush object.
*
* This is an overloaded constructor, provided for convenience. It behaves
* like the preceding constructor, except the conical gradient parameters
* specified as a center point \a c and angle \a a in radians.
*/
ConicalGradientBrush( const DPoint& c, double a, const stop_list& stops = stop_list() );
/*!
* Constructs a %ConicalGradientBrush object.
*
* This is an overloaded constructor, provided for convenience. It behaves
* like the preceding constructor, except the conical gradient parameters
* specified as a center point \a c and angle \a a in radians.
*/
ConicalGradientBrush( const Point& c, double a, const stop_list& stops = stop_list() );
/*!
* Copy constructor. This object will reference the same server-side brush
* as the specified instance \a b.
*/
ConicalGradientBrush( const ConicalGradientBrush& b )
: GradientBrush( b )
{
}
/*!
* Move constructor.
*/
ConicalGradientBrush( ConicalGradientBrush&& x )
: GradientBrush( std::move( x ) )
{
}
/*!
* Assignment operator. Returns a reference to this object.
*
* Makes this object reference the same server-side brush as the specified
* instance \a b. If the previous brush becomes unreferenced, it will be
* garbage-collected by the PixInsight core application.
*/
ConicalGradientBrush& operator =( const ConicalGradientBrush& b )
{
SetHandle( b.handle );
return *this;
}
/*!
* Move assignment operator. Returns a reference to this object.
*/
ConicalGradientBrush& operator =( ConicalGradientBrush&& x )
{
Transfer( x );
return *this;
}
/*!
* Retrieves the conical gradient parameters of this object.
*
* \param[out] cx,cy Coordinates of the gradient's center.
* \param[out] a Gradient's angle in radians.
*
* \sa GetParameters( DPoint&, double& )
*/
void GetParameters( double& cx, double& cy, double& a ) const;
/*!
* Returns the conical gradient parameters of this object.
*
* This is an overloaded function, provided for convenience. It behaves like
* the preceding function, except the center coordinates are retrieved as a
* DPoint object.
*
* \sa GetParameters( double&, double&, double& )
*/
void GetParameters( DPoint& c, double& a ) const
{
GetParameters( c.x, c.y, a );
}
};
// ----------------------------------------------------------------------------
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
} // pcl
#endif // __PCL_Brush_h
// ----------------------------------------------------------------------------
// EOF pcl/Brush.h - Released 2022-03-12T18:59:29Z
-430
View File
@@ -1,430 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Button.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Button_h
#define __PCL_Button_h
/// \file pcl/Button.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/Control.h>
#include <pcl/Bitmap.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::CheckState
* \brief Button check states
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>CheckState::Unchecked</td> <td>The control is not checked</td></tr>
* <tr><td>CheckState::Checked</td> <td>The control is checked</td></tr>
* <tr><td>CheckState::ThirdState</td> <td>The check box is in its 'third state'</td></tr>
* </table>
*
*/
namespace CheckState
{
enum value_type
{
Unchecked, // the item is not checked
Checked, // the item is checked
ThirdState // the check box is in its 'third state'
};
}
// ----------------------------------------------------------------------------
/*!
* \class Button
* \brief Abstract base class for all client-side interfaces to PixInsight
* button controls.
*
* ### TODO: Write a detailed description for Button
*/
class PCL_CLASS Button : public Control
{
public:
/*!
* Represents a button check state. Supported values are defined in the
* CheckState namespace.
*/
typedef CheckState::value_type check_state;
/*!
* Destroys a %Button control.
*/
virtual ~Button()
{
}
/*!
* Returns the current button text.
*/
String Text() const;
/*!
* Sets the current button text.
*/
void SetText( const String& );
/*!
* Returns the current icon shown by this button, or a null Bitmap object if
* this button has no associated icon.
*/
Bitmap Icon() const;
/*!
* Sets the icon shown by this button. If a null Bitmap object is specified,
* no icon will be associated with this button.
*/
void SetIcon( const Bitmap& );
/*!
* Obtains the current icon dimensions of this button in pixels. The icon's
* \a width and \a height are returned in the referenced variables.
*/
void GetIconSize( int& width, int& height ) const;
/*!
* Returns the current icon width in pixels for this button.
*/
int IconWidth() const
{
int width, dum; GetIconSize( width, dum ); return width;
}
/*!
* Returns the current icon height in pixels for this button.
*/
int IconHeight() const
{
int dum, height; GetIconSize( dum, height ); return height;
}
/*!
* Sets new icon sizes for this button, \a width and \a height in pixels,
* respectively.
*/
void SetIconSize( int width, int height );
/*! #
*/
void SetIconSize( int size )
{
SetIconSize( size, size );
}
/*! #
*/
void GetScaledIconSize( int& width, int& height ) const
{
GetIconSize( width, height ); width = PhysicalPixelsToLogical( width ); height = PhysicalPixelsToLogical( height );
}
/*! #
*/
int ScaledIconWidth() const
{
int width, dum; GetIconSize( width, dum ); return PhysicalPixelsToLogical( width );
}
/*! #
*/
int ScaledIconHeight() const
{
int dum, height; GetIconSize( dum, height ); return PhysicalPixelsToLogical( height );
}
/*! #
*/
void SetScaledIconSize( int width, int height )
{
SetIconSize( LogicalPixelsToPhysical( width ), LogicalPixelsToPhysical( height ) );
}
/*! #
*/
void SetScaledIconSize( int size )
{
size = LogicalPixelsToPhysical( size );
SetIconSize( size, size );
}
/*!
* Returns true iff this button can be <em>pushed down</em>.
*
* \note This is a pure virtual member function that must be reimplemented
* by derived classes.
*/
virtual bool IsPushable() const = 0;
/*!
* Returns true iff this button is in <em>pushed down</em> state.
*/
bool IsPushed() const;
/*!
* Sets the current push state of this button.
*/
void SetPushed( bool = true );
/*!
* A convenience synonym for SetPushed( true ).
*/
void Push()
{
SetPushed( true );
}
/*!
* A convenience synonym for SetPushed( false ).
*/
void Unpush()
{
SetPushed( false );
}
/*!
* Returns true iff this button can be <em>checked</em>.
*
* \note This is a pure virtual member function that must be reimplemented
* by derived classes.
*/
virtual bool IsCheckable() const = 0;
/*!
* Returns true iff this button is in <em>checked state</em>.
*/
bool IsChecked() const;
/*!
* Sets the current check state of this button.
*/
void SetChecked( bool = true );
/*!
* A convenience synonym for SetChecked( true ).
*/
void Check()
{
SetChecked( true );
}
/*!
* A convenience synonym for SetChecked( false ).
*/
void Uncheck()
{
SetChecked( false );
}
/*!
* Returns the current check state of this button. This function must be
* used for button controls that can adopt \e tristate check states.
*/
check_state State() const;
/*!
* Sets the current check state of this button. This function must be used
* for button controls that can adopt \e tristate check states.
*/
void SetState( check_state );
// -------------------------------------------------------------------------
// Event handlers
//
// void OnClick( Button& sender, bool checked );
// void OnPress( Button& sender );
// void OnRelease( Button& sender );
// void OnCheck( Button& sender, Button::check_state state );
/*!
* \defgroup button_event_handlers Button Event Handlers
*/
/*!
* Defines the prototype of a <em>button click event handler</em>.
*
* A button click event is generated when a button control is clicked with
* the mouse (pressed down then released while the mouse cursor stays within
* the button) or activated with the keyboard.
*
* \param sender The control that sends a button click event.
* \param checked Whether the sender button is currently checked.
*
* \ingroup button_event_handlers
*/
typedef void (Control::*click_event_handler)( Button& sender, bool checked );
/*!
* Defines the prototype of a <em>button press event handler</em>.
*
* A button press event is generated when a button control is either pressed
* down with the mouse, or released after having being pressed.
*
* \param sender The control that sends a button press event.
*
* \ingroup button_event_handlers
*/
typedef void (Control::*press_event_handler)( Button& sender );
/*!
* Defines the prototype of a <em>button check event handler</em>.
*
* A button check event is generated when a checkable button control changes
* its check state, either by clicking it with the mouse, or by activating
* it with the keyboard.
*
* \param sender The control that sends a button press event.
* \param state The current check state of the sender button.
*
* \ingroup button_event_handlers
*/
typedef void (Control::*check_event_handler)( Button& sender, Button::check_state state );
/*!
* Sets the button click event handler for this button.
*
* \param handler The button click event handler. Must be a member
* function of the receiver object's class.
*
* \param receiver The control that will receive click events from this
* button.
*
* \ingroup button_event_handlers
*/
void OnClick( click_event_handler handler, Control& receiver );
/*!
* Sets the button press event handler for this button.
*
* \param handler The button press event handler. Must be a member
* function of the receiver object's class.
*
* \param receiver The control that will receive press events from this
* button.
*
* \ingroup button_event_handlers
*/
void OnPress( press_event_handler handler, Control& receiver );
/*!
* Sets the button release event handler for this button.
*
* \param handler The button release event handler. Must be a member
* function of the receiver object's class.
*
* \param receiver The control that will receive release events from this
* button.
*
* \ingroup button_event_handlers
*/
void OnRelease( press_event_handler handler, Control& receiver );
/*!
* Sets the button check event handler for this button.
*
* \param handler The button check event handler. Must be a member
* function of the receiver object's class.
*
* \param receiver The control that will receive check events from this
* button.
*
* \ingroup button_event_handlers
*/
void OnCheck( check_event_handler handler, Control& receiver );
private:
struct EventHandlers
{
click_event_handler onClick = nullptr;
press_event_handler onPress = nullptr;
press_event_handler onRelease = nullptr;
check_event_handler onCheck = nullptr;
EventHandlers() = default;
EventHandlers( const EventHandlers& ) = default;
EventHandlers& operator =( const EventHandlers& ) = default;
};
AutoPointer<EventHandlers> m_handlers;
protected:
/*!
* \internal
*/
Button( void* h ) : Control( h )
{
}
friend class ButtonEventDispatcher;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
#endif // __PCL_Button_h
// ----------------------------------------------------------------------------
// EOF pcl/Button.h - Released 2022-03-12T18:59:29Z
-135
View File
@@ -1,135 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/ButtonCodes.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_ButtonCodes_h
#define __PCL_ButtonCodes_h
/// \file pcl/ButtonCodes.h
#include <pcl/Defs.h>
#include <pcl/Flags.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::MouseButton
* \brief Defines PCL mouse button codes
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>MouseButton::Left</td> <td>Primary mouse button</td></tr>
* <tr><td>MouseButton::Right</td> <td>Secondary mouse button</td></tr>
* <tr><td>MouseButton::Middle</td> <td>Middle mouse button</td></tr>
* <tr><td>MouseButton::X1</td> <td>First X button</td></tr>
* <tr><td>MouseButton::X2</td> <td>Second X button</td></tr>
* <tr><td>MouseButton::Unknown</td> <td>Unknown/unsupported mouse button</td></tr>
* </table>
*/
namespace MouseButton
{
enum mask_type
{
Left = 0x01, // Primary mouse button
Right = 0x02, // Secondary mouse button
Middle = 0x04, // Middle mouse button
X1 = 0x10, // First X button
X2 = 0x20, // Second X button
Unknown = 0 // Unknown/unsupported mouse button
};
}
/*!
* A combination of mouse button codes.
*/
typedef Flags<MouseButton::mask_type> MouseButtons;
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::KeyModifier
* \brief Defines PCL keyboard modifiers
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>KeyModifier::Shift</td> <td>Shift key</td></tr>
* <tr><td>KeyModifier::Control</td> <td>Control key (Command key on macOS)</td></tr>
* <tr><td>KeyModifier::Alt</td> <td>Alt key</td></tr>
* <tr><td>KeyModifier::SpaceBar</td> <td>Space bar</td></tr>
* <tr><td>KeyModifier::Meta</td> <td>Meta key (Control key on macOS)</td></tr>
* </table>
*/
namespace KeyModifier
{
enum mask_type
{
Shift = 0x01, // Shift key
Control = 0x02, // Control key (= Command on macOS)
Alt = 0x04, // Alt key
SpaceBar = 0x08, // Space bar
Meta = 0x10 // Meta key (= Control on macOS)
};
}
/*!
* A combination of keyboard modifiers.
*/
typedef Flags<KeyModifier::mask_type> KeyModifiers;
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_ButtonCodes_h
// ----------------------------------------------------------------------------
// EOF pcl/ButtonCodes.h - Released 2022-03-12T18:59:29Z
-100
View File
@@ -1,100 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/ByteArray.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_ByteArray_h
#define __PCL_ByteArray_h
/// \file pcl/ByteArray.h
#include <pcl/Defs.h>
#include <pcl/Array.h>
#include <pcl/SortedArray.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \defgroup byte_arrays Byte Array Classes
*/
/*!
* \class pcl::ByteArray
* \brief Dynamic array of 8-bit unsigned integers
*
* %ByteArray is a template instantiation of Array for \c uint8.
*
* \ingroup byte_arrays
* \ingroup dynamic_arrays
*/
typedef Array<uint8> ByteArray;
/*!
* \class pcl::SortedByteArray
* \brief Dynamic sorted array of 8-bit unsigned integers
*
* %SortedByteArray is a template instantiation of SortedArray for \c uint8.
*
* \ingroup byte_arrays
* \ingroup dynamic_arrays
*/
typedef SortedArray<uint8> SortedByteArray;
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_ByteArray_h
// ----------------------------------------------------------------------------
// EOF pcl/ByteArray.h - Released 2022-03-12T18:59:29Z
-131
View File
@@ -1,131 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/CUDADevice.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_CUDADevice_h
#define __PCL_CUDADevice_h
/// \file pcl/CUDADevice.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/String.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class CUDADevice
* \brief Access to core CUDA device services
*
* ### TODO: Write description.
*/
class PCL_CLASS CUDADevice
{
public:
/*!
* Default constructor - deleted, not an instantiable class.
*/
CUDADevice() = delete;
/*!
* Copy constructor - deleted, not an instantiable class.
*/
CUDADevice( const CUDADevice& ) = delete;
/*!
* Copy assignment operator - deleted, not an instantiable class.
*/
CUDADevice& operator =( CUDADevice& ) = delete;
/*!
* Returns true iff a valid and operational CUDA device is currently
* available on the running PixInsight platform.
*/
static bool IsAvailable() noexcept;
/*!
* Returns the identifying name of the active CUDA device, or an empty
* string if there is no valid CUDA device available on the running
* PixInsight platform.
*/
static IsoString Name();
/*!
* Returns the total global memory available on the active CUDA device in
* bytes, or zero if no valid CUDA device is available.
*/
static size_type TotalGlobalMemory() noexcept;
/*!
* Returns the total shared memory available per block on the active CUDA
* device in bytes, or zero if no valid CUDA device is available.
*/
static size_type SharedMemoryPerBlock() noexcept;
/*!
* Returns the maximum number of threads per block available in the active
* CUDA device, or zero if no valid CUDA device is available.
*/
static int MaxThreadsPerBlock() noexcept;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_CUDADevice_h
// ----------------------------------------------------------------------------
// EOF pcl/CUDADevice.h - Released 2022-03-12T18:59:29Z
-190
View File
@@ -1,190 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/CanvasColor.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_CanvasColor_h
#define __PCL_CanvasColor_h
/// \file pcl/CanvasColor.h
#include <pcl/Defs.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class CanvasColor
* \brief A set of color values used to fill free or unused areas of images
*
* Some geometric image transformations, such as rotations and translations for
* example, generate images with uncovered regions. %CanvasColor defines a set
* of color components to initialize pixels on such unused areas.
*
* %CanvasColor stores pixel values in a normalized floating-point format
* suitable to be used for any pixel sample data type. When using %CanvasColor
* with integer-sampled images, color components should be kept normalized in
* the normalized [0,1] range.
*/
class PCL_CLASS CanvasColor
{
public:
/*!
* Constructs a %CanvasColor object with zero (black) color components.
*/
CanvasColor() = default;
/*!
* Copy constructor.
*/
CanvasColor( const CanvasColor& ) = default;
/*!
* Copy assignment operator. Returns a reference to this object.
*/
CanvasColor& operator =( const CanvasColor& ) = default;
/*!
* Retrieves the current RGB sample values in this %CanvasColor object.
*
* \param[out] v0,v1,v2 References to variables that will receive current
* sample values for the red/gray, green and blue
* channels, respectively.
*/
void GetCanvasColor( float& v0, float& v1, float& v2 ) const
{
v0 = canvasColor[0]; v1 = canvasColor[1]; v2 = canvasColor[2];
}
/*!
* Retrieves the current RGBA sample values in this %CanvasColor object.
*
* \param[out] v0,v1,v2,v3 References to variables that will receive
* current sample values for the red/gray, green, blue and
* alpha channels, respectively.
*/
void GetCanvasColor( float& v0, float& v1, float& v2, float& v3 ) const
{
v0 = canvasColor[0]; v1 = canvasColor[1]; v2 = canvasColor[2]; v3 = canvasColor[3];
}
/*!
* Retrieves the current sample values in this %CanvasColor object.
*
* \param[out] v Starting address of an array where current sample values
* will be copied. This array must provide storage for at
* least four elements.
*/
void GetCanvasColor( float* v ) const
{
v[0] = canvasColor[0]; v[1] = canvasColor[1]; v[2] = canvasColor[2]; v[3] = canvasColor[3];
}
/*!
* Sets current RGB sample values for this %CanvasColor object.
*
* \param v0,v1,v2 New red/gray, green and blue sample values.
*
* \note The alpha component will be set to one (white, opaque).
*/
void SetCanvasColor( float v0, float v1, float v2 )
{
canvasColor[0] = v0; canvasColor[1] = v1; canvasColor[2] = v2; canvasColor[3] = 1;
}
/*!
* Sets current RGB sample values for this %CanvasColor object.
*
* \param v0,v1,v2,v3 New red/gray, green, blue and alpha sample values.
*
* \note The alpha component will be set to one (white, opaque).
*/
void SetCanvasColor( float v0, float v1, float v2, float v3 )
{
canvasColor[0] = v0; canvasColor[1] = v1; canvasColor[2] = v2; canvasColor[3] = v3;
}
/*!
* Sets current sample values for this %CanvasColor object.
*
* \param v Starting address of an array from which new sample values
* will be obtained. At least four elements are required.
*/
void SetCanvasColor( const float* v )
{
canvasColor[0] = v[0]; canvasColor[1] = v[1]; canvasColor[2] = v[2]; canvasColor[3] = v[3];
}
/*!
* Sets all sample values of this %CanvasColor object equal to an specified
* value \a v.
*/
void SetCanvasColor( float v )
{
canvasColor[0] = canvasColor[1] = canvasColor[2] = canvasColor[3] = v;
}
protected:
// Normalized floating-point sample values. Note that to the purpose of this
// structure float provides enough accuracy, even for DImage.
float canvasColor[ 4 ] = {}; // red/gray, green, blue, alpha
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_CanvasColor_h
// ----------------------------------------------------------------------------
// EOF pcl/CanvasColor.h - Released 2022-03-12T18:59:29Z
-1453
View File
File diff suppressed because it is too large Load Diff
-945
View File
@@ -1,945 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/ChebyshevFit.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_ChebyshevFit_h
#define __PCL_ChebyshevFit_h
/// \file pcl/ChebyshevFit.h
#include <pcl/Defs.h>
#include <pcl/Constants.h>
#include <pcl/ErrorHandler.h>
#include <pcl/Exception.h>
#include <pcl/MultiVector.h>
namespace pcl
{
// ----------------------------------------------------------------------------
template <typename Tx, typename Ty> class GenericScalarChebyshevFit;
/*!
* \class GenericChebyshevFit
* \brief Approximation of vector-valued functions by Chebyshev polynomial
* expansions.
*
* %GenericChebyshevFit approximates a smooth, vector-valued function f(x) in a
* given interval [a,b] by expansion with a set of truncated series of
* Chebyshev polynomials. As is well known, the Chebyshev expansion:
*
* T(x) = Sum_i( ci*Ti(x) ),
*
* where i belongs to [0,&infin;), Ti(x) is the Chebyshev polynomial of the ith
* degree, and the ci's are polynomial coefficients, is very close to the
* optimal approximating polynomial that minimizes the error |T(x) - f(x)|,
* where x varies over the fitting interval [a,b].
*
* For functions converging strongly after a given series length n, one can
* truncate the Chebyshev series to a smaller length m < n to obtain an
* approximating polynomial with a maximum error close to |Tm+1(x)|.
*
* In addition to Chebyshev expansion, truncation and approximation, this class
* also implements generation of Chebyshev polynomials to approximate the
* first derivative and indefinite integral of the fitted function.
*
* The template argument Tx represents the type of the independent variable, or
* the type of the argument x of the fitted function y = f(x). The template
* argument Ty represents the type of a component of the value y of the fitted
* function.
*/
template <typename Tx, typename Ty>
class GenericChebyshevFit
{
public:
/*!
* Represents an ordered list of Chebyshev polynomial coefficients.
*/
typedef GenericVector<Ty> coefficients;
/*!
* Represents a set of ordered lists of Chebyshev polynomial coefficients.
*/
typedef GenericMultiVector<Ty> coefficient_series;
/*!
* Represents a function value.
*/
typedef GenericVector<Ty> function_value;
/*!
* Represents a set of function values.
*/
typedef GenericMultiVector<Ty> function_values;
/*!
* Constructs a truncated Chebyshev polynomial expansion with \a n
* coefficients to approximate the specified N-dimensional, vector-valued
* function \a f in the interval [\a x1,\a x2] of the independent variable.
*
* The function \a f will be called \a n times and should have the following
* prototype (or equivalent by means of suitable type conversions and/or
* default arguments):
*
* GenericVector&lt;Ty&gt; f( Tx )
*
* where the length of a returned vector must be equal to \a N.
*
* The expansion process will compute n^2 + n cosines, which may dominate the
* complexity of the process if the function \a f is comparatively fast.
*
* The interval [\a x1,\a x2] must not be empty or insignificant with
* respect to the machine epsilon. If that happens, this constructor will
* throw an appropriate Error exception. The interval bounds can be
* specified in any order, that is, \a x2 can legally be < \a x1; in such
* case the bounds will be implicitly swapped by this constructor.
*
* The interval [\a x1,\a x2] will be also the valid range of evaluation for
* this object, which can be retrieved with LowerBound() and UpperBound().
* See also the Evaluate() member function.
*
* The length \a n of the polynomial coefficient series should be &ge; 2. If
* \a n &le; 1, the specified value will be ignored and \a n = 2 will be
* forced. Typically, a relatively large series length should be used, say
* between 30 and 100 coefficients, depending on the rate and amplitude of
* function variations within the fitting interval. The polynomial expansion
* can be further truncated to approximate the function to the desired error
* bound. See the Truncate() and Evaluate() member functions for details.
*/
template <class F>
GenericChebyshevFit( F f, Tx x1, Tx x2, int N, int n )
: dx( Abs( x2 - x1 ) )
, x0( (x1 + x2)/2 )
, m( Max( 2, n ), Max( 1, N ) )
{
PCL_PRECONDITION( N > 0 )
PCL_PRECONDITION( n > 1 )
if ( 1 + dx == 1 )
throw Error( "GenericChebyshevFit: Empty or insignificant function evaluation interval." );
N = m.Length();
n = m[0];
Tx dx2 = dx/2;
function_values y( n, N );
for ( int j = 0; j < n; ++j )
y[j] = f( x0 + Cos( Const<Ty>::pi()*(j + 0.5)/n )*dx2 );
c = coefficient_series( N, n );
Ty k = 2.0/n;
for ( int i = 0; i < N; ++i )
for ( int j = 0; j < n; ++j )
{
Ty s = Ty( 0 );
for ( int k = 0; k < n; ++k )
s += y[k][i] * Cos( Const<Ty>::pi()*j*(k + 0.5)/n );
c[i][j] = k*s;
}
}
/*!
* Constructs a truncated Chebyshev polynomial expansion from the specified
* coefficient series \a ck to approximate a vector-valued function in the
* interval [\a x1,\a x2] of the independent variable. The dimension of the
* approximated function and the coefficient series lengths are acquired
* from the specified container \a ck.
*
* This constructor performs basic coherence and structural integrity checks
* on the specified parameters, and throws the appropriate Error exception
* if it detects any problem. However, the validity of polynomial expansion
* coefficients cannot be verified; ensuring it is the responsibility of the
* caller.
*/
GenericChebyshevFit( const coefficient_series& ck, Tx x1, Tx x2 )
: dx( Abs( x2 - x1 ) )
, x0( (x1 + x2)/2 )
, c( ck )
, m( int( ck.Length() ) )
{
if ( 1 + dx == 1 )
throw Error( "GenericChebyshevFit: Empty or insignificant function evaluation interval." );
if ( c.IsEmpty() )
throw Error( "GenericChebyshevFit: Empty polynomial expansion." );
for ( int i = 0; i < m.Length(); ++i )
if ( (m[i] = c[i].Length()) < 1 )
throw Error( "GenericChebyshevFit: Invalid coefficient series for dimension " + String( i ) + '.' );
}
/*!
* Default constructor.
*
* Constructs an invalid, uninitialized object that cannot be used to
* perform function evaluations. A default-constructed %GenericChebyshevFit
* object should be assigned with an already initialized instance in order
* to become operative.
*
* \sa IsValid()
*/
GenericChebyshevFit() = default;
/*!
* Copy constructor.
*/
GenericChebyshevFit( const GenericChebyshevFit& ) = default;
/*!
* Move constructor.
*/
GenericChebyshevFit( GenericChebyshevFit&& ) = default;
/*!
* Copy assignment operator. Returns a reference to this object.
*/
GenericChebyshevFit& operator =( const GenericChebyshevFit& ) = default;
/*!
* Move assignment operator. Returns a reference to this object.
*/
GenericChebyshevFit& operator =( GenericChebyshevFit&& ) = default;
/*!
* Returns true if this object has been correctly initialized and can be
* used to perform function evaluations. Returns false if this is an
* uninitialized, default-constructed object
*/
bool IsValid() const
{
return !c.IsEmpty();
}
/*!
* Returns the lower bound of this Chebyshev fit. This is the smallest value
* of the independent variable for which the function has been fitted, and
* hence the smallest value for which this object can be legally evaluated
* for function approximation.
*
* \sa UpperBound()
*/
Tx LowerBound() const
{
return x0 - dx/2;
}
/*!
* Returns the upper bound of this Chebyshev fit. This is the largest value
* of the independent variable for which the function has been fitted, and
* hence the largest value for which this object can be legally evaluated
* for function approximation.
*
* \sa LowerBound()
*/
Tx UpperBound() const
{
return x0 + dx/2;
}
/*!
* Returns the number of components in the (vector-valued) dependent
* variable. This is the number of vector components in a fitted or
* approximated function value.
*/
int NumberOfComponents() const
{
return m.Length();
}
/*!
* Returns the number of coefficients in the generated Chebyshev polynomial
* expansion for the specified zero-based vector component index \a i. This
* is the number of coefficients that was specified or acquired in a class
* constructor.
*
* \sa TruncatedLength()
*/
int Length( int i = 0 ) const
{
PCL_PRECONDITION( i >= 0 && i < NumberOfComponents() )
return c[i].Length();
}
/*!
* Returns the number of coefficients in the truncated Chebyshev polynomial
* expansion for the specified zero-based vector component index \a i.
*
* If \a i < 0, returns the largest number of polynomial coefficients among
* all vector components.
*
* \sa Truncate(), Length()
*/
int TruncatedLength( int i = -1 ) const
{
PCL_PRECONDITION( i < 0 || i < NumberOfComponents() )
if ( i < 0 )
return m.MaxComponent();
return m[i];
}
/*!
* Returns the total number of coefficients in this Chebyshev polynomial
* expansion, or the sum of computed coefficients for all vector components.
*
* \sa NumberOfTruncatedCoefficients()
*/
int NumberOfCoefficients() const
{
int N = 0;
for ( int i = 0; i < NumberOfComponents(); ++i )
N += c[i].Length();
return N;
}
/*!
* Returns the total number of coefficients in the truncated Chebyshev
* polynomial expansion, or the sum of the lengths of the truncated
* coefficients series for all vector components.
*
* \sa NumberOfCoefficients()
*/
int NumberOfTruncatedCoefficients() const
{
return m.Sum();
}
/*!
* Returns true iff the Chebyshev polynomial expansion has been truncated
* for the specified zero-based vector component index \a i.
*
* If \a i < 0, returns true iff the expansions have been truncated for all
* vector components.
*
* \sa Truncate(), TruncatedLength()
*/
bool IsTruncated( int i = -1 ) const
{
PCL_PRECONDITION( i < 0 || i < NumberOfComponents() )
if ( i < 0 )
return m.MaxComponent() < Length();
return m[i] < c[i].Length();
}
/*!
* Returns an estimate of the maximum error in the truncated Chebyshev
* polynomial expansion for the specified zero-based vector component index
* \a i.
*
* If \a i < 0, returns the largest expansion error estimate among all
* vector components.
*
* \sa Truncate()
*/
Ty TruncationError( int i = -1 ) const
{
PCL_PRECONDITION( i < 0 || i < NumberOfComponents() )
if ( i < 0 )
{
int N = NumberOfComponents();
function_value e( N );
for ( int j = 0; j < N; ++j )
e[j] = TruncationError( j );
return e.MaxComponent();
}
if ( m[i] < c[i].Length() )
{
Ty e = Ty( 0 );
for ( int j = c[i].Length(); --j >= m[i]; )
e += Abs( c[i][j] );
return e;
}
return Abs( c[i][c[i].Length()-1] );
}
/*!
* Attempts to truncate the Chebyshev polynomial expansion for the specified
* maximum error \a e. Returns \c true iff the expansion could be truncated
* successfully for all vector components of the fitted function.
*
* If n is the length of a fitted polynomial series, this function finds a
* truncated length 1 &lt; m &le; n such that:
*
* Sum_i( |ci| ) < e
*
* where ci is a polynomial coefficient and the zero-based subindex i is in
* the interval [m,n-1].
*
* The truncated Chebyshev expansion will approximate the fitted function
* component with a maximum error close to &plusmn;|e| within the fitting
* interval.
*
* The optional parameter \a mmin is the minimum allowed length of a
* coefficient series. The value of this parameter is 2 by default, which is
* the minimum number of Chebyshev coefficients in a series expansion.
* Specifying a value greater than 2 can be useful sometimes to impose
* stricter accuracy constraints on the truncated series.
*
* This member function does not remove any polynomial coefficients, so the
* original polynomial expansion remains intact. This means that the fitted
* polynomials can be truncated successively to achieve different error
* bounds, as required.
*
* If the polynomial series cannot be truncated to achieve the required
* tolerance in all function components (that is, if either all coefficients
* for a given component are larger than \a e in absolute value, or n = 2),
* this function forces m = n for the components where the requested
* truncation is not feasible, yielding the original, untruncated Chebyshev
* polynomials for those components. In such case this function returns
* \c false.
*/
bool Truncate( Ty e, int mmin = 2 )
{
e = Abs( e );
mmin = Max( 2, mmin );
int N = NumberOfComponents();
int tc = 0;
for ( int i = 0; i < N; ++i )
{
Ty s = Ty( 0 );
for ( m[i] = c[i].Length(); m[i] > mmin; --m[i] )
if ( (s += Abs( c[i][m[i]-1] )) >= e )
break;
if ( m[i] < c[i].Length() )
++tc;
}
return tc == N;
}
/*!
* Returns a reference to the immutable set of Chebyshev polynomial
* expansion coefficients in this object.
*/
const coefficient_series& Coefficients() const
{
return c;
}
/*!
* Evaluates the truncated Chebyshev polynomial expansion for the specified
* value \a x of the independent variable, and returns the approximated
* function value.
*
* The specified evaluation point \a x must lie within the fitting interval,
* given by LowerBound() and UpperBound(), which was specified as the \a x1
* and \a x2 arguments when the function was initially fitted by the class
* constructor. For performance reasons, this precondition is not verified
* by this member function. If an out-of-range evaluation point is
* specified, this function will return an unpredictable result.
*
* If the polynomial series has been truncated by calling Truncate(), this
* function evaluates the current truncated Chebyshev expansions instead of
* the original ones.
*
* \sa operator ()()
*/
function_value Evaluate( Tx x ) const
{
PCL_PRECONDITION( x >= LowerBound() )
PCL_PRECONDITION( x <= UpperBound() )
const Ty y0 = Ty( 2*(x - x0)/dx );
const Ty y2 = 2*y0;
function_value y( NumberOfComponents() );
for ( int i = 0; i < y.Length(); ++i )
{
Ty d0 = Ty( 0 );
Ty d1 = Ty( 0 );
const Ty* k = c[i].At( m[i] );
for ( int j = m[i]; --j > 0; )
{
Ty d = d1;
d1 = y2*d1 - d0 + *--k;
d0 = d;
}
y[i] = y0*d1 - d0 + *--k/2;
}
return y;
}
/*!
* A synonym for Evaluate().
*/
function_value operator ()( Tx x ) const
{
return Evaluate( x );
}
/*!
* Returns a %GenericChebyshevFit object that approximates the derivative of
* the function fitted by this object.
*
* The returned object can be used to evaluate the derivative within the
* fitting interval of this object, defined by LowerBound() and
* UpperBound().
*
* The returned object will always own Chebyshev polynomials with the length
* of the originally fitted series, \e not of the current truncated lengths,
* if the polynomial expansions have been truncated.
*
* \sa Integral()
*/
GenericChebyshevFit Derivative() const
{
int N = NumberOfComponents();
GenericChebyshevFit ch1;
ch1.dx = dx;
ch1.x0 = x0;
ch1.c = coefficient_series( N );
ch1.m = IVector( N );
for ( int i = 0; i < N; ++i )
{
int n = Max( 1, c[i].Length()-1 );
ch1.c[i] = coefficients( n );
ch1.m[i] = n;
if ( n > 1 )
{
ch1.c[i][n-1] = 2*n*c[i][n];
ch1.c[i][n-2] = 2*(n-1)*c[i][n-1];
for ( int j = n-3; j >= 0; --j )
ch1.c[i][j] = ch1.c[i][j+2] + 2*(j+1)*c[i][j+1];
ch1.c[i] *= Ty( 2 )/dx;
}
else
ch1.c[i] = Ty( 0 );
}
return ch1;
}
/*!
* Returns a %GenericChebyshevFit object that approximates the indefinite
* integral of the function fitted by this object.
*
* The returned object can be used to evaluate the integral within the
* fitting interval of this object, as defined by LowerBound() and
* UpperBound(). The constant of integration is set to a value such that the
* integral is zero at the lower fitting bound.
*
* The returned object will always own Chebyshev polynomials with the length
* of the originally fitted series, \e not of the current truncated lengths,
* if the polynomial expansions have been truncated.
*
* \sa Derivative()
*/
GenericChebyshevFit Integral() const
{
int N = NumberOfComponents();
GenericChebyshevFit ch;
ch.dx = dx;
ch.x0 = x0;
ch.c = coefficient_series( N );
ch.m = IVector( N );
for ( int i = 0; i < N; ++i )
{
int n = c[i].Length();
ch.c[i] = coefficients( n );
ch.m[i] = n;
if ( n > 1 )
{
const Ty k = Ty( dx )/4;
Ty s = Ty( 0 );
int f = 1;
for ( int j = 1; j < n-1; ++j, f = -f )
s += f*(ch.c[i][j] = k*(c[i][j-1] - c[i][j+1])/j);
ch.c[i][0] = 2*(s + f*(ch.c[i][n-1] = k*c[i][n-2]/(n-1)));
}
else
ch.c[i] = Ty( 0 );
}
return ch;
}
private:
Tx dx; // x2 - x1
Tx x0; // (x1 + x2)/2
coefficient_series c; // Chebyshev polynomial coefficients
IVector m; // length of the truncated coefficient series
friend class GenericScalarChebyshevFit<Tx,Ty>;
};
// ----------------------------------------------------------------------------
/*!
* \class GenericScalarChebyshevFit
* \brief Approximation of scalar-valued functions by Chebyshev polynomial
* expansion.
*
* %GenericScalarChebyshevFit approximates a smooth, scalar-valued function
* f(x) in a given interval [a,b] by expansion with a single truncated series
* of Chebyshev polynomials. %GenericScalarChebyshevFit is a convenient
* specialization of GenericChebyshevFit for functions returning a single
* value; refer to the parent class for complete information.
*/
template <typename Tx, typename Ty>
class GenericScalarChebyshevFit : public GenericChebyshevFit<Tx,Ty>
{
public:
/*!
* Constructs a truncated Chebyshev polynomial expansion with \a n
* coefficients to approximate the specified N-dimensional, scalar-valued
* function \a f in the interval [\a x1,\a x2] of the independent variable.
*
* See GenericChebyshevFit::GenericChebyshevFit() for detailed information.
*/
template <class F>
GenericScalarChebyshevFit( F f, Tx x1, Tx x2, int n )
: GenericChebyshevFit<Tx,Ty>( [f]( Tx x ){ return GenericVector<Ty>( f( x ), 1 ); }, x1, x2, 1, n )
{
}
/*!
* Default constructor.
*
* Constructs an invalid, uninitialized object that cannot be used to
* perform function evaluations. A default-constructed
* %GenericScalarChebyshevFit object should be assigned with an already
* initialized instance in order to become operative.
*
* \sa IsValid()
*/
GenericScalarChebyshevFit() = default;
/*!
* Copy constructor.
*/
GenericScalarChebyshevFit( const GenericScalarChebyshevFit& ) = default;
/*!
* Move constructor.
*/
GenericScalarChebyshevFit( GenericScalarChebyshevFit&& ) = default;
/*!
* Copy assignment operator.
*/
GenericScalarChebyshevFit& operator =( const GenericScalarChebyshevFit& ) = default;
/*!
* Move assignment operator.
*/
GenericScalarChebyshevFit& operator =( GenericScalarChebyshevFit&& ) = default;
/*!
* Returns the number of coefficients in the truncated Chebyshev polynomial
* expansion.
*
* \sa Truncate(), Length()
*/
int TruncatedLength() const
{
return GenericChebyshevFit<Tx,Ty>::TruncatedLength( 0 );
}
/*!
* Returns true iff the Chebyshev polynomial expansion has been truncated.
*
* \sa Truncate(), TruncatedLength()
*/
bool IsTruncated() const
{
return GenericChebyshevFit<Tx,Ty>::IsTruncated( 0 );
}
/*!
* Returns an estimate of the maximum error in the truncated Chebyshev
* polynomial expansion.
*
* \sa Truncate()
*/
Ty TruncationError() const
{
return GenericChebyshevFit<Tx,Ty>::TruncationError( 0 );
}
/*!
* Evaluates the truncated Chebyshev polynomial expansion for the specified
* value \a x of the independent variable, and returns the approximated
* function value.
*
* \sa operator ()()
*/
Ty Evaluate( Tx x ) const
{
return GenericChebyshevFit<Tx,Ty>::Evaluate( x )[0];
}
/*!
* A synonym for Evaluate().
*/
Ty operator ()( Tx x ) const
{
return Evaluate( x );
}
/*!
* Returns a %GenericChebyshevFit object that approximates the derivative of
* the function fitted by this object.
*
* See GenericChebyshevFit::Derivative() for detailed information.
*
* \sa Integral()
*/
GenericScalarChebyshevFit Derivative() const
{
return GenericChebyshevFit<Tx,Ty>::Derivative();
}
/*!
* Returns a %GenericChebyshevFit object that approximates the indefinite
* integral of the function fitted by this object.
*
* See GenericChebyshevFit::Integral() for detailed information.
*
* \sa Derivative()
*/
GenericScalarChebyshevFit Integral() const
{
return GenericChebyshevFit<Tx,Ty>::Integral();
}
private:
/*!
* \internal
* Private constructor from the base class.
*/
GenericScalarChebyshevFit( const GenericChebyshevFit<Tx,Ty>& T )
: GenericChebyshevFit<Tx,Ty>()
{
this->dx = T.dx;
this->x0 = T.x0;
this->c = typename GenericChebyshevFit<Tx,Ty>::coefficient_series( 1 );
this->c[0] = T.c[0];
this->m = IVector( 1 );
this->m[0] = T.m[0];
}
};
// ----------------------------------------------------------------------------
#ifndef __PCL_NO_CHEBYSHEV_FIT_INSTANTIATE
/*!
* \defgroup chebyshev_fit_types Chebyshev Fit Types
*/
/*!
* \class pcl::F32ChebyshevFit
* \ingroup chebyshev_fit_types
* \brief 32-bit floating point Chebyshev function approximation.
*
* %F32ChebyshevFit is a template instantiation of GenericChebyshevFit for the
* \c float type.
*/
typedef GenericChebyshevFit<float, float> F32ChebyshevFit;
/*!
* \class pcl::FChebyshevFit
* \ingroup chebyshev_fit_types
* \brief 32-bit floating point Chebyshev function approximation.
*
* %FChebyshevFit is an alias for F32ChebyshevFit. It is a template
* instantiation of GenericChebyshevFit for the \c float type.
*/
typedef F32ChebyshevFit FChebyshevFit;
/*!
* \class pcl::F64ChebyshevFit
* \ingroup chebyshev_fit_types
* \brief 64-bit floating point Chebyshev function approximation.
*
* %F64ChebyshevFit is a template instantiation of GenericChebyshevFit for the
* \c double type.
*/
typedef GenericChebyshevFit<double, double> F64ChebyshevFit;
/*!
* \class pcl::DChebyshevFit
* \ingroup chebyshev_fit_types
* \brief 64-bit floating point Chebyshev function approximation.
*
* %DChebyshevFit is an alias for F64ChebyshevFit. It is a template
* instantiation of GenericChebyshevFit for the \c double type.
*/
typedef F64ChebyshevFit DChebyshevFit;
/*!
* \class pcl::ChebyshevFit
* \ingroup chebyshev_fit_types
* \brief 64-bit floating point Chebyshev function approximation.
*
* %ChebyshevFit is an alias for DChebyshevFit. It is a template instantiation
* of GenericChebyshevFit for the \c double type.
*/
typedef DChebyshevFit ChebyshevFit;
#ifndef _MSC_VER
/*!
* \class pcl::F80ChebyshevFit
* \ingroup chebyshev_fit_types
* \brief 80-bit extended precision floating point Chebyshev function
* approximation.
*
* %F80ChebyshevFit is a template instantiation of GenericChebyshevFit for the
* \c long \c double type.
*
* \note This template instantiation is not available on Windows with Visual
* C++ compilers.
*/
typedef GenericChebyshevFit<long double, long double> F80ChebyshevFit;
/*!
* \class pcl::LDChebyshevFit
* \ingroup chebyshev_fit_types
* \brief 80-bit extended precision floating point Chebyshev function
* approximation.
*
* %LDChebyshevFit is an alias for F80ChebyshevFit. It is a template
* instantiation of GenericChebyshevFit for the \c long \c double type.
*
* \note This template instantiation is not available on Windows with Visual
* C++ compilers.
*/
typedef F80ChebyshevFit LDChebyshevFit;
#endif // !_MSC_VER
/*!
* \class pcl::F32ScalarChebyshevFit
* \ingroup chebyshev_fit_types
* \brief 32-bit floating point scalar Chebyshev function approximation.
*
* %F32ScalarChebyshevFit is a template instantiation of
* GenericScalarChebyshevFit for the \c float type.
*/
typedef GenericScalarChebyshevFit<float, float> F32ScalarChebyshevFit;
/*!
* \class pcl::FScalarChebyshevFit
* \ingroup chebyshev_fit_types
* \brief 32-bit floating point scalar Chebyshev function approximation.
*
* %FScalarChebyshevFit is an alias for F32ScalarChebyshevFit. It is a template
* instantiation of GenericScalarChebyshevFit for the \c float type.
*/
typedef F32ScalarChebyshevFit FScalarChebyshevFit;
/*!
* \class pcl::F64ScalarChebyshevFit
* \ingroup chebyshev_fit_types
* \brief 64-bit floating point scalar Chebyshev function approximation.
*
* %F64ScalarChebyshevFit is a template instantiation of
* GenericScalarChebyshevFit for the \c double type.
*/
typedef GenericScalarChebyshevFit<double, double> F64ScalarChebyshevFit;
/*!
* \class pcl::DScalarChebyshevFit
* \ingroup chebyshev_fit_types
* \brief 64-bit floating point scalar Chebyshev function approximation.
*
* %DScalarChebyshevFit is an alias for F64ScalarChebyshevFit. It is a template
* instantiation of GenericScalarChebyshevFit for the \c double type.
*/
typedef F64ScalarChebyshevFit DScalarChebyshevFit;
/*!
* \class pcl::ScalarChebyshevFit
* \ingroup chebyshev_fit_types
* \brief 64-bit floating point scalar Chebyshev function approximation.
*
* %ScalarChebyshevFit is an alias for DScalarChebyshevFit. It is a template
* instantiation of GenericScalarChebyshevFit for the \c double type.
*/
typedef DScalarChebyshevFit ScalarChebyshevFit;
#ifndef _MSC_VER
/*!
* \class pcl::F80ScalarChebyshevFit
* \ingroup chebyshev_fit_types
* \brief 80-bit extended precision floating point scalar Chebyshev function
* approximation.
*
* %F80ScalarChebyshevFit is a template instantiation of
* GenericScalarChebyshevFit for the \c long \c double type.
*
* \note This template instantiation is not available on Windows with Visual
* C++ compilers.
*/
typedef GenericScalarChebyshevFit<long double, long double> F80ScalarChebyshevFit;
/*!
* \class pcl::LDScalarChebyshevFit
* \ingroup chebyshev_fit_types
* \brief 80-bit extended precision floating point scalar Chebyshev function
* approximation.
*
* %LDScalarChebyshevFit is an alias for F80ScalarChebyshevFit. It is a
* template instantiation of GenericScalarChebyshevFit for the \c long
* \c double type.
*
* \note This template instantiation is not available on Windows with Visual
* C++ compilers.
*/
typedef F80ScalarChebyshevFit LDScalarChebyshevFit;
#endif // !_MSC_VER
#endif // !__PCL_NO_CHEBYSHEV_FIT_INSTANTIATE
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_ChebyshevFit_h
// ----------------------------------------------------------------------------
// EOF pcl/ChebyshevFit.h - Released 2022-03-12T18:59:29Z
-129
View File
@@ -1,129 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/CheckBox.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_CheckBox_h
#define __PCL_CheckBox_h
/// \file pcl/CheckBox.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/Button.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class CheckBox
* \brief Client-side interface to a PixInsight %CheckBox control
*
* ### TODO: Write a detailed description for %CheckBox
*/
class PCL_CLASS CheckBox : public Button
{
public:
/*!
* Constructs a %CheckBox with the specified \a text, as a child control of
* \a parent.
*/
CheckBox( const String& text = String(), Control& parent = Control::Null() );
/*!
* Destroys a %CheckBox control.
*/
virtual ~CheckBox()
{
}
/*!
* Returns \c false, since check boxes are not pushable buttons.
*/
bool IsPushable() const override
{
return false;
}
/*!
* Returns \c true, since check boxes are checkable buttons.
*/
bool IsCheckable() const override
{
return true;
}
/*!
* Returns \c true only if this check box can have three states.
*/
bool IsTristateMode() const;
/*!
* Enables or disables \e tristate \e mode. In tristate mode, a check box
* can have three states: checked, unchecked, and \e semi-checked (also
* called \e third \e state).
*/
void SetTristateMode( bool = true );
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
#endif // __PCL_CheckBox_h
// ----------------------------------------------------------------------------
// EOF pcl/CheckBox.h - Released 2022-03-12T18:59:29Z
-161
View File
@@ -1,161 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Checksum.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Checksum_h
#define __PCL_Checksum_h
/// \file pcl/Checksum.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/ByteArray.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \defgroup checksum_functions Checksum Calculation Functions
*/
/*!
* Returns the <em>standard checksum</em> value calculated for a data sequence.
* The returned value is the total number of bits set in the sequence of input
* data bytes.
*
* \param data Address of the first byte in the data sequence.
* \param length Length in bytes of the data sequence.
*
* \ingroup checksum_functions
* \sa Checksum( const C& )
*/
size_type PCL_FUNC inline Checksum( const void* data, size_type length )
{
PCL_PRECONDITION( data != nullptr )
size_type S = 0;
for ( const uint8* p = (const uint8*)data, * p1 = p+length; p < p1; ++p )
{
uint8 b = *p;
if ( b & 0x01 ) ++S;
if ( b & 0x02 ) ++S;
if ( b & 0x04 ) ++S;
if ( b & 0x08 ) ++S;
if ( b & 0x10 ) ++S;
if ( b & 0x20 ) ++S;
if ( b & 0x40 ) ++S;
if ( b & 0x80 ) ++S;
}
return S;
}
/*!
* Returns the <em>standard checksum</em> value for a container.
*
* \param data Reference to a container whose standard checksum will be
* calculated. The checksum number will be generated for the
* current data bytes in this container instance.
*
* \ingroup checksum_functions
* \sa Checksum( const void*, size_type )
*/
template <class C> inline
uint32 Checksum( const C& data )
{
return Checksum( data.Begin(), sizeof( *(data.Begin()) )*data.Length() );
}
/*!
* Returns the CRC-32 error-detecting code calculated for a data sequence.
*
* \param data Address of the first byte in the data sequence.
* \param length Length in bytes of the data sequence.
*
* \b References
*
* CRC calculation routine based on original code by Michael Barr. The employed
* code requires the following copyright notice:
*
* <em>Copyright (c) 2000 by Michael Barr. This software is placed into the
* public domain and may be used for any purpose. However, this notice must
* not be changed or removed and no warranty is either expressed or implied by
* its publication or distribution.</em>
*
* \ingroup checksum_functions
* \sa CRC32( const C& )
*/
uint32 PCL_FUNC CRC32( const void* data, size_type length );
/*!
* Returns the CRC-32 error-detecting code for a container.
*
* \param data Reference to a container whose CRC-32 checksum will be
* calculated. The checksum code will be generated for the
* current data bytes in this container instance.
*
* \ingroup checksum_functions
* \sa CRC32( const void*, size_type )
*/
template <class C> inline
uint32 CRC32( const C& data )
{
return CRC32( data.Begin(), sizeof( *(data.Begin()) )*data.Length() );
}
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_Checksum_h
// ----------------------------------------------------------------------------
// EOF pcl/Checksum.h - Released 2022-03-12T18:59:29Z
-894
View File
@@ -1,894 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/CodeEditor.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_CodeEditor_h
#define __PCL_CodeEditor_h
/// \file pcl/CodeEditor.h
#include <pcl/Defs.h>
#include <pcl/Flags.h>
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/AutoPointer.h>
#include <pcl/Control.h>
#endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::FindMode
* \brief Flags to control text find and replacement operations.
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>FindMode::RegExp</td> <td>Search with a regular expression instead of a literal substring.</td></tr>
* <tr><td>FindMode::Backward</td> <td>Search toward the beginning of the document.</td></tr>
* <tr><td>FindMode::CaseSensitive</td> <td>Perform a case-sensitive search.</td></tr>
* <tr><td>FindMode::WholeWords</td> <td>Search for whole words only.</td></tr>
* <tr><td>FindMode::SelectionOnly</td> <td>Search and replace within the current text selection only</td></tr>
* <tr><td>FindMode::Incremental</td> <td>Perform an incremental text find operation. The search begins after a previously matched text block.</td></tr>
* <tr><td>FindMode::Default</td> <td>The default text find mode, equal to FindMode::CaseSensitive|FindMode::WholeWords.</td></tr>
* </table>
*/
namespace FindMode
{
enum mask_type
{
RegExp = 0x00000001, // Search with a regular expression
Backward = 0x00000010, // Search toward the beginning of text
CaseSensitive = 0x00000020, // Case-sensitive search
WholeWords = 0x00000040, // Search for whole words
SelectionOnly = 0x00000100, // Replace within the current selection
Incremental = 0x00000200, // Perform an incremental find operation
Default = CaseSensitive|WholeWords
};
}
/*!
* A combination of text find and replacement mode flags.
*/
typedef Flags<FindMode::mask_type> FindModes;
// ----------------------------------------------------------------------------
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
// ----------------------------------------------------------------------------
/*!
* \class CodeEditor
* \brief Client-side interface to a PixInsight %CodeEditor control.
*
* ### TODO: Write a detailed description for %CodeEditor.
*/
class PCL_CLASS CodeEditor : public Control
{
public:
/*!
* Constructs a %CodeEditor control.
*
* \param parent The parent control of this object. The default value is
* a null control.
*/
CodeEditor( Control& parent = Control::Null() );
/*!
* Destroys a %CodeEditor control.
*/
virtual ~CodeEditor()
{
}
/*!
* Returns a reference to a <em>line numbers control</em> for this code
* editor.
*
* A line numbers control provides a visual index of the text lines
* currently displayed by a code editor. Typically, a code editor and its
* line numbers control are packed side by side in a HorizontalSizer.
*/
Control& LineNumbersControl();
/*!
* Returns the absolute file path associated with this code editor, or an
* empty string if this object has not been associated with a file.
*/
String FilePath() const;
/*!
* Sets the file path associated with this code editor.
*
* If the specified \a path includes a file name suffix (also known as file
* name \e extension), the control will use it to identify a programming
* language to perform automatic syntax highlighting of the text in the
* editor. Currently the following file suffixes and source code languages
* are supported:
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>.js .jsh</td> <td>JavaScript source files</td></tr>
* <tr><td>.scp</td> <td>Command-line script files</td></tr>
* <tr><td>.cpp .h .cxx .hpp .hxx .c .cc</td> <td>C/C++ source files</td></tr>
* <tr><td>.py</td> <td>Python source files</td></tr>
* <tr><td>.xml .xhtml .html .xosm .xpsm (among others)</td> <td>XML source files</td></tr>
* <tr><td>.pidoc</td> <td>PixInsight documentation source files</td></tr>
* <tr><td>.pm .pmath</td> <td>PixelMath source files</td></tr>
* </table>
*
* Unrecognized (or absent) file suffixes effectively disable the automatic
* syntax highlighting feature. The default value of this parameter is an
* empty string.
*/
void SetFilePath( const String& path );
/*!
* Returns the current text in this code editor in UTF-16 format.
*/
String Text() const;
/*!
* Sets the current text in this code editor in UTF-16 format.
*/
void SetText( const String& text );
/*!
* Returns an encoded 8-bit representation of the text in this code editor.
*
* \param encoding The desired text encoding. Currently only the "UTF-8"
* and "ISO-8859-1" encodings are supported. The default
* value is "UTF-8".
*/
IsoString EncodedText( const IsoString& encoding = "UTF-8" ) const;
/*!
* Returns the text in this code editor encoded in UTF-8 format.
*
* This is a convenience function, equivalent to:
*
* \code EncodedText( "UTF-8" ); \endcode
*/
IsoString TextUTF8() const
{
return EncodedText( "UTF-8" );
}
/*!
* Returns the text in this code editor encoded in ISO 8859-1 format.
*
* This is a convenience function, equivalent to:
*
* \code EncodedText( "ISO-8859-1" ); \endcode
*/
IsoString TextISO88591() const
{
return EncodedText( "ISO-8859-1" );
}
/*!
* Sets the current text in this code editor, encoded in an 8-bit format.
*
* \param text The encoded 8-bit text.
*
* \param encoding The text encoding. Currently only the "UTF-8" and
* "ISO-8859-1" encodings are supported. The default value
* is "UTF-8".
*/
void SetEncodedText( const IsoString& text, const IsoString& encoding = "UTF-8" );
/*!
* Sets the current text in this code editor, encoded in UTF-8 format.
*
* This is a convenience function, equivalent to:
*
* \code SetEncodedText( text, "UTF-8" ); \endcode
*/
void SetTextUTF8( const IsoString& text )
{
SetEncodedText( text, "UTF-8" );
}
/*!
* Sets the current text in this code editor, encoded in ISO 8859-1 format.
*
* This is a convenience function, equivalent to:
*
* \code SetEncodedText( text, "ISO-8859-1" ); \endcode
*/
void SetTextISO88591( const IsoString& text )
{
SetEncodedText( text, "ISO-8859-1" );
}
/*!
* Clears all the text in this code editor. Also clears all undo/redo
* buffers, so this action is irreversible.
*/
void ClearText();
/*!
* Returns true iff this code editor is in <em>read-only mode</em>. A
* read-only editor does not allow any command that can modify its text
* contents as a result of a direct user interaction. The text can only be
* changed programmatically for a read-only code editor.
*/
bool IsReadOnly() const;
/*!
* Enables the read-only mode for this code editor. A read-only editor does
* not allow any command that can modify its text contents as a result of a
* direct user interaction. The text can only be changed programmatically
* for a read-only code editor.
*
* \param readOnly Whether to enable or disable the read-only mode for
* this code editor.
*/
void SetReadOnly( bool readOnly = true );
/*!
* Writes the text in this code editor to the specified file, encoded in an
* 8-bit format.
*
* \param filePath Path to the destination file.
*
* \param encoding The desired text encoding. Currently only the "UTF-8"
* and "ISO-8859-1" encodings are supported. The default
* value is "UTF-8".
*
* Returns true if the file was successfully written; false in the event of
* error.
*
* \warning Upon successful completion, this function will overwrite an
* existing file at the specified path, whose previous contents will be
* lost.
*/
bool Save( const String& filePath, const IsoString& encoding = "UTF-8" );
/*!
* Writes the text in this code editor to the specified file, encoded in
* UTF-8 format.
*
* This is a convenience function, equivalent to:
*
* \code Save( filePath, "UTF-8" ); \endcode
*/
bool SaveUTF8( const String& filePath )
{
return Save( filePath, "UTF-8" );
}
/*!
* Writes the text in this code editor to the specified file, encoded in
* ISO 8859-1 format.
*
* This is a convenience function, equivalent to:
*
* \code Save( filePath, "ISO-8859-1" ); \endcode
*/
bool SaveISO88591( const String& filePath )
{
return Save( filePath, "ISO-8859-1" );
}
/*!
* Reads an encoded 8-bit text file and loads it in this code editor.
*
* \param filePath Path to the source file.
*
* \param encoding The text encoding. Currently only the "UTF-8" and
* "ISO-8859-1" encodings are supported. The default
* value is "UTF-8".
*
* Returns true if the file was successfully read; false in the event of
* error.
*/
bool Load( const String& filePath, const IsoString& encoding = "UTF-8" );
/*!
* Reads a text file encoded in UTF-8 format, and loads it in this code
* editor.
*
* This is a convenience function, equivalent to:
*
* \code Load( filePath, "UTF-8" ); \endcode
*/
bool LoadUTF8( const String& filePath )
{
return Load( filePath, "UTF-8" );
}
/*!
* Reads a text file encoded in ISO 8859-1 format, and loads it in this code
* editor.
*
* This is a convenience function, equivalent to:
*
* \code Load( filePath, "ISO-8859-1" ); \endcode
*/
bool LoadISO88591( const String& filePath )
{
return Load( filePath, "ISO-8859-1" );
}
/*!
* Returns the number of text lines (including empty lines) in this code
* editor.
*/
int NumberOfLines() const;
/*!
* Returns the total number of characters in the current text of this code
* editor.
*/
int NumberOfCharacters() const;
/*!
* Returns the current cursor position in visual coordinates. The returned
* object stores the current line and column of the cursor in its Point::y
* and Point::x public data members, respectively.
*
* Line and column coordinates are counted from zero. Line numbers range
* from zero to the number of existing text lines minus one. There is no
* specific limit for the number of text characters in a text line.
*/
Point CursorPosition() const;
/*!
* Returns the line number of the current cursor position.
*/
int CursorLine() const
{
return CursorPosition().y;
}
/*!
* Returns the column number of the current cursor position.
*/
int CursorColumn() const
{
return CursorPosition().x;
}
/*!
* Sets the current cursor position in this code editor to the specified
* \a line and \a column. See CursorPosition() for more information on
* visual text coordinates.
*/
void SetCursorPosition( int line, int column );
/*!
* Sets the current cursor position in this code editor through the
* coordinates of a Point object. The new cursor line will be set to
* \a pos.y and the new cursor column to \a pos.x, respectively.
*/
void SetCursorPosition( const Point& pos )
{
SetCursorPosition( pos.y, pos.x );
}
/*!
* Returns true iff this code editor is in <em>insert text mode</em>. Returns
* false if the editor is in <em>replace text mode</em>.
*
* In insert mode, newly generated text by direct user interaction is
* inserted at the current cursor location. In replace mode, newly generated
* text replaces existing characters starting at the current cursor
* location. The insert text mode is always enabled by default.
*/
bool IsInsertMode() const;
/*!
* Enables the <em>insert text mode</em> for this code editor.
*
* \param insert Whether to enable the insert text mode (if true) or the
* replace text mode (if false). The default value is true.
*/
void SetInsertMode( bool insert = true );
/*!
* Enables the <em>replace text mode</em> for this code editor.
*
* \param replace Whether to enable the replace text mode (if true) or the
* insert text mode (if false). The default value is true.
*/
void SetReplaceMode( bool replace = true )
{
SetInsertMode( !replace );
}
/*!
* Returns true iff this code editor is in <em>block selection mode</em>;
* false if it is in <em>line selection mode</em>.
*
* In block selection mode, the user can select rectangular areas of text
* across multiple text lines. In <em>line selection mode</em>, text
* selections can only include entire text lines except for the first and
* last lines in a selection. The line selection mode is always enabled by
* default.
*/
bool IsBlockSelectionMode() const;
/*!
* Enables the block selection mode for this code editor.
*
* \param blockMode Whether to enable the block selection mode (if true) or
* the line selection mode (if false). The default value
* is true.
*/
void SetBlockSelectionMode( bool blockMode = true );
/*!
* Enables the line selection mode for this code editor.
*
* \param lineMode Whether to enable the line selection mode (if true) or
* the block selection mode (if false). The default value
* is true.
*/
void SetLineSelectionMode( bool lineMode = true )
{
SetBlockSelectionMode( !lineMode );
}
/*!
* Returns true iff this code editor is in <em>dynamic word wrap mode</em>.
*
* In dynamic word wrap mode, long text lines extending beyond the visible
* width of the editor's viewport are automatically truncated and continued
* on successive editor lines, so that the user can always see the entire
* contents of all text lines, and a horizontal scroll bar is never shown.
*
* When the dynamic word wrap mode is disabled, long text lines are never
* truncated and the editor shows a horizontal scroll bar when necessary.
* The dynamic word wrap mode is always disabled by default.
*/
bool IsDynamicWordWrapMode() const;
/*!
* Enables the dynamic word wrap mode for this code editor.
*
* \param wrapMode Whether to enable the dynamic word wrap mode.
*/
void SetDynamicWordWrapMode( bool wrapMode = true );
/*!
* Returns the number of \e undo steps available for this code editor.
*/
int UndoSteps() const;
/*!
* Returns the number of \e redo steps available for this code editor.
*/
int RedoSteps() const;
/*!
* Returns true iff this code editor has a text selection defined.
*/
bool HasSelection() const;
/*!
* Returns the visual coordinates of the current selection in this code
* editor. The selection coordinates are stored in the returned rectangle as
* follows:
*
* \li Rect::y0 - Starting line of the current text selection.
* \li Rect::x0 - Starting column of the current text selection.
* \li Rect::y1 - Ending line of the current text selection.
* \li Rect::x1 - Ending column of the current text selection.
*/
Rect Selection() const;
/*!
* Sets a new text selection defined by its visual coordinates.
*
* \param fromLine Starting line of the new text selection.
* \param fromCol Starting column of the new text selection.
* \param toLine Ending line of the new text selection.
* \param toCol Ending column of the new text selection.
*/
void SetSelection( int fromLine, int fromCol, int toLine, int toCol );
/*!
* Sets a new text selection defined by its visual coordinates.
*
* This is a convenience function, equivalent to:
*
* \code SetSelection( r.y0, r.x0, r.y1, r.x1 ); \endcode
*/
void SetSelection( const Rect& r )
{
SetSelection( r.y0, r.x0, r.y1, r.x1 );
}
/*!
* Returns the currently selected text in this code editor, or an empty
* string if this editor has no selection currently defined.
*/
String SelectedText() const;
/*!
* Inserts the specified \a text at the current cursor location.
*
* If there is a selection defined, the selected text is replaced with the
* inserted \a text.
*/
void InsertText( const String& text );
/*!
* Undoes the last editor action. If no action can be undone, this function
* has no effect.
*/
void Undo();
/*!
* Redoes the last editor action. If no action can be redone, this function
* has no effect.
*/
void Redo();
/*!
* Copies the current text selection to the clipboard and removes the
* selected text. If no selection is defined, this function has no effect.
*/
void Cut();
/*!
* Copies the current text selection to the clipboard. If no selection is
* defined, this function has no effect.
*/
void Copy();
/*!
* Inserts the contents of the clipboard at the current cursor location. If
* the clipboard is empty, or if its contents cannot be converted to plain
* text, this function has no effect.
*/
void Paste();
/*!
* Removes the currently selected text. If there is no text selection
* defined, this function has no effect.
*/
void Delete();
/*!
* Selects all the text in this code editor.
*/
void SelectAll();
/*!
* Clears the current text selection, if any. This function simply unselects
* the text; it does not remove the selected text.
*/
void Unselect();
/*!
* If the cursor points to a bracket or parenthesis character, look for a
* matching pair and move the cursor to the corresponding location.
*
* Returns true iff a matching pair could be found. If there is no bracket or
* parenthesis at the current cursor location, or if a matched pair couldn't
* be found, this function returns false and the cursor is not moved.
*/
bool GotoMatchedParenthesis();
/*!
* Highlights all occurrences of a literal text string or a regular
* expression.
*
* \param toFind The text or regular expression to search for, depending on
* the specified \a mode flags.
*
* \param mode An OR'ed combination of flags to control the text find
* operation. Valid flags are enumerated in the pcl::FindMode
* namespace.
*
* The operation takes place on the whole text document, ignoring the
* FindMode::Backward and FindMode::SelectionOnly flags. Returns the number
* of matches found.
*/
int HighlightAllMatches( const String& toFind, FindModes mode );
/*!
* Clears all text highlightings. This function does not remove the
* highlighted text; it simply clears the visual highlight indications.
*/
void ClearMatches();
/*!
* Finds an occurrence of a literal text string or a regular expression.
*
* \param toFind The text or regular expression to search for, depending on
* the specified \a mode flags.
*
* \param mode An OR'ed combination of flags to control the text find
* operation. Valid flags are enumerated in the pcl::FindMode
* namespace.
*
* Returns true iff a match was found.
*/
bool Find( const String& toFind, FindModes mode );
/*!
* Replaces the current selection with the specified text.
*
* \param replaceWith The text that will replace the current selection.
* Can be an empty string (to delete the current
* selection).
*
* If there is some text selected in this editor, this function returns
* true after performing the replacement operation. If there is no text
* currently selected, this function is ignored and false is returned.
*/
bool ReplaceSelection( const String& replaceWith );
/*!
* Replaces all occurrences of a literal text string or a regular
* expression with the specified text.
*
* \param toFind The text or regular expression to search for, depending on
* the specified \a mode flags.
*
* \param replaceWith The text that will replace all matches found. Can be
* an empty string (to delete all matched occurrences).
*
* \param mode An OR'ed combination of flags to control the text find and
* replace operation. Valid flags are enumerated in the
* pcl::FindMode namespace.
*
* Returns the number of matches found and replaced.
*
*/
int ReplaceAll( const String& toFind, const String& replaceWith, FindModes mode );
/*!
* \defgroup code_editor_event_handlers CodeEditor Event Handlers
*/
/*!
* Defines the prototype of an <em>editor event handler</em>.
*
* An editor event is generated when a %CodeEditor instance changes its
* state or contents due to direct user interaction.
*
* \param sender The control that sends an editor event.
*
* \ingroup code_editor_event_handlers
*/
typedef void (Control::*editor_event_handler)( CodeEditor& sender );
/*!
* Defines the prototype of a <em>cursor event handler</em>.
*
* A cursor event is generated when the cursor position changes in a
* %CodeEditor instance due to direct user interaction.
*
* \param sender The control that sends a cursor event.
*
* \param line Line number of the new cursor position (>= 0).
*
* \param col Column number of the new cursor position (>= 0).
*
* \ingroup code_editor_event_handlers
*/
typedef void (Control::*cursor_event_handler)( CodeEditor& sender, int line, int col );
/*!
* Defines the prototype of a <em>selection event handler</em>.
*
* A selection event is generated when the text selection changes in a
* %CodeEditor instance due to direct user interaction.
*
* \param sender The control that sends a selection event.
*
* \param fromLine Line number of the starting position of the new text
* selection.
*
* \param fromCol Column number of the starting position of the new text
* selection.
*
* \param toLine Line number of the ending position of the new text
* selection.
*
* \param toCol Column number of the ending position of the new text
* selection.
*
* \ingroup code_editor_event_handlers
*/
typedef void (Control::*selection_event_handler)( CodeEditor& sender, int fromLine, int fromCol, int toLine, int toCol );
/*!
* Defines the prototype of a <em>state event handler</em>.
*
* A state event is generated when a Boolean property changes in a
* %CodeEditor instance due to direct user interaction.
*
* \param sender The control that sends a cursor event.
*
* \param state New property state.
*
* \ingroup code_editor_event_handlers
*/
typedef void (Control::*state_event_handler)( CodeEditor& sender, bool state );
/*!
* Sets the handler for <em>text updated</em> events generated by this code
* editor. A text updated event is generated each time the text changes in
* this editor as a result of a direct user interaction.
*
* \param handler The event handler. Must be a member function of the
* \a receiver object's class.
*
* \param receiver The control that will receive text updated events from
* this code editor.
*
* \ingroup code_editor_event_handlers
*/
void OnTextUpdated( editor_event_handler handler, Control& receiver );
/*!
* Sets the handler for <em>cursor position updated</em> events generated by
* this code editor. A cursor position updated event is generated each time
* the text cursor (also known as \e caret) moves in this editor as a result
* of a direct user interaction.
*
* \param handler The event handler. Must be a member function of the
* \a receiver object's class.
*
* \param receiver The control that will receive cursor position updated
* events from this code editor.
*
* \ingroup code_editor_event_handlers
*/
void OnCursorPositionUpdated( cursor_event_handler handler, Control& receiver );
/*!
* Sets the handler for <em>selection updated</em> events generated by this
* code editor. A selection updated event is generated each time the text
* selection is changed in this editor as a result of a direct user
* interaction.
*
* \param handler The event handler. Must be a member function of the
* \a receiver object's class.
*
* \param receiver The control that will receive selection updated events
* from this code editor.
*
* \ingroup code_editor_event_handlers
*/
void OnSelectionUpdated( selection_event_handler handler, Control& receiver );
/*!
* Sets the handler for <em>overwrite mode updated</em> events generated by
* this code editor. An overwrite mode updated event is generated each time
* the overwrite mode is enabled or disabled in this editor (i.e., from
* overwrite mode to replace mode or vice-versa) as a result of a direct
* user interaction.
*
* \param handler The event handler. Must be a member function of the
* \a receiver object's class.
*
* \param receiver The control that will receive overwrite mode updated
* events from this code editor.
*
* \ingroup code_editor_event_handlers
*/
void OnOverwriteModeUpdated( state_event_handler handler, Control& receiver );
/*!
* Sets the handler for <em>selection mode updated</em> events generated by
* this code editor. A selection mode updated event is generated each time
* the selection mode is changed in this editor (i.e., from line selection
* mode to block selection mode or vice-versa) as a result of a direct user
* interaction.
*
* \param handler The event handler. Must be a member function of the
* \a receiver object's class.
*
* \param receiver The control that will receive selection mode updated
* events from this code editor.
*
* \ingroup code_editor_event_handlers
*/
void OnSelectionModeUpdated( state_event_handler handler, Control& receiver );
/*!
* Sets the handler for <em>dynamic word wrap mode updated</em> events
* generated by this code editor. A dynamic word wrap mode updated event is
* generated each time the dynamic word wrap mode is enabled or disabled in
* this editor as a result of a direct user interaction.
*
* \param handler The event handler. Must be a member function of the
* \a receiver object's class.
*
* \param receiver The control that will receive dynamic word wrap mode
* updated events from this code editor.
*
* \ingroup code_editor_event_handlers
*/
void OnDynamicWordWrapModeUpdated( state_event_handler handler, Control& receiver );
private:
struct EventHandlers
{
editor_event_handler onTextUpdated = nullptr;
cursor_event_handler onCursorPositionUpdated = nullptr;
selection_event_handler onSelectionUpdated = nullptr;
state_event_handler onOverwriteModeUpdated = nullptr;
state_event_handler onSelectionModeUpdated = nullptr;
state_event_handler onDynamicWordWrapModeUpdated = nullptr;
EventHandlers() = default;
EventHandlers( const EventHandlers& ) = default;
EventHandlers& operator =( const EventHandlers& ) = default;
};
AutoPointer<EventHandlers> m_handlers;
Control m_lineNumbers;
friend class CodeEditorEventDispatcher;
};
// ----------------------------------------------------------------------------
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
} // pcl
#endif // __PCL_CodeEditor_h
// ----------------------------------------------------------------------------
// EOF pcl/CodeEditor.h - Released 2022-03-12T18:59:29Z
-412
View File
@@ -1,412 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Color.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Color_h
#define __PCL_Color_h
/// \file pcl/Color.h
#include <pcl/Defs.h>
#include <pcl/Math.h>
#include <pcl/String.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \defgroup rgba_utility_functions RGBA Color Utility Functions
*/
/*!
* Defines a 32-bit RGBA pixel value.
*
* A %RGBA pixel value is encoded as follows:
*
* <tt>AARRGGBB</tt>
*
* where each letter represents a 4-bit hexadecimal digit (from 0 to F). Each
* 8-bit pair represents a pixel component in the range from 0 to 255:
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td><tt>AA</tt></td> <td>Alpha value, or <em>pixel transparency</em>:
* 0 means completely transparent, 255 corresponds to an
* opaque pixel.</td></tr>
* <tr><td><tt>RR</tt></td> <td>Red pixel color component.</td></tr>
* <tr><td><tt>GG</tt></td> <td>Green pixel color component.</td></tr>
* <tr><td><tt>BB</tt></td> <td>Blue pixel color component.</td></tr>
* </table>
*
* \ingroup rgba_utility_functions
*/
typedef uint32 RGBA;
/*!
* Returns the alpha (transparency) component of an RGBA pixel value.
*
* \ingroup rgba_utility_functions
*/
inline uint8 Alpha( RGBA rgba )
{
return uint8( rgba >> 24 );
}
/*!
* Returns the red color component of an RGBA pixel value.
*
* \ingroup rgba_utility_functions
*/
inline uint8 Red( RGBA rgba )
{
return uint8( rgba >> 16 );
}
/*!
* Returns the green color component of an RGBA pixel value.
*
* \ingroup rgba_utility_functions
*/
inline uint8 Green( RGBA rgba )
{
return uint8( rgba >> 8 );
}
/*!
* Returns the blue color component of an RGBA pixel value.
*
* \ingroup rgba_utility_functions
*/
inline uint8 Blue( RGBA rgba )
{
return uint8( rgba );
}
/*!
* Clears (sets to zero) the alpha (transparency) component of an RGBA pixel
* value.
*
* \ingroup rgba_utility_functions
*/
inline void ClearAlpha( RGBA& rgba )
{
rgba &= 0x00fffffful;
}
/*!
* Clears (sets to zero) the red color component of an RGBA pixel value.
*
* \ingroup rgba_utility_functions
*/
inline void ClearRed( RGBA& rgba )
{
rgba &= 0xff00fffful;
}
/*!
* Clears (sets to zero) the green color component of an RGBA pixel value.
*
* \ingroup rgba_utility_functions
*/
inline void ClearGreen( RGBA& rgba )
{
rgba &= 0xffff00fful;
}
/*!
* Clears (sets to zero) the blue color component of an RGBA pixel value.
*
* \ingroup rgba_utility_functions
*/
inline void ClearBlue( RGBA& rgba )
{
rgba &= 0xffffff00ul;
}
/*!
* Sets the alpha (transparency) component of an RGBA pixel value.
*
* \ingroup rgba_utility_functions
*/
inline void SetAlpha( RGBA& rgba, uint8 a )
{
ClearAlpha( rgba ); rgba |= uint32( a ) << 24;
}
/*!
* Sets the red color component of an RGBA pixel value.
*
* \ingroup rgba_utility_functions
*/
inline void SetRed( RGBA& rgba, uint8 r )
{
ClearRed( rgba ); rgba |= uint32( r ) << 16;
}
/*!
* Sets the green color component of an RGBA pixel value.
*
* \ingroup rgba_utility_functions
*/
inline void SetGreen( RGBA& rgba, uint8 g )
{
ClearGreen( rgba ); rgba |= uint32( g ) << 8;
}
/*!
* Sets the blue color component of an RGBA pixel value.
*
* \ingroup rgba_utility_functions
*/
inline void SetBlue( RGBA& rgba, uint8 b )
{
ClearBlue( rgba ); rgba |= uint32( b );
}
/*!
* Returns an RGBA pixel value for the specified separate alpha and color
* component integer values.
*
* \param r Red color component
* \param g Green color component
* \param b Blue color component
* \param a Alpha (transparency)
*
* All components must be in the range [0,255].
*
* \ingroup rgba_utility_functions
*/
inline RGBA RGBAColor( int r, int g, int b, int a )
{
return (uint32( a ) << 24) | (uint32( r ) << 16) | (uint32( g ) << 8) | uint32( b );
}
/*!
* Returns an opaque RGBA pixel value for the specified separate color
* component integer values.
*
* \param r Red color component
* \param g Green color component
* \param b Blue color component
*
* All components must be in the range [0,255]. The returned RGBA value has its
* alpha component equal to 255 (opaque).
*
* \ingroup rgba_utility_functions
*/
inline RGBA RGBAColor( int r, int g, int b )
{
return 0xff000000ul | (uint32( r ) << 16) | (uint32( g ) << 8) | uint32( b );
}
/*!
* Returns an RGBA pixel value for the specified separate alpha and color
* component real values.
*
* \param r Red color component
* \param g Green color component
* \param b Blue color component
* \param a Alpha (transparency)
*
* All components must be in the normalized range [0,1].
*
* \ingroup rgba_utility_functions
*/
inline RGBA RGBAColor( double r, double g, double b, double a )
{
return RGBAColor( RoundInt( 255*r ), RoundInt( 255*g ), RoundInt( 255*b ), RoundInt( 255*a ) );
}
/*!
* Returns an RGBA pixel value for the specified separate alpha and color
* component real values.
*
* \param r Red color component
* \param g Green color component
* \param b Blue color component
* \param a Alpha (transparency)
*
* All components must be in the normalized range [0,1].
*
* \ingroup rgba_utility_functions
*/
inline RGBA RGBAColor( float r, float g, float b, float a )
{
return RGBAColor( double( r ), double( g ), double( b ), double( a ) );
}
/*!
* Returns an opaque RGBA pixel value for the specified separate color
* component real values.
*
* \param r Red color component
* \param g Green color component
* \param b Blue color component
*
* All components must be in the normalized range [0,1]. The returned RGBA
* value has its alpha component equal to 255 (opaque).
*
* \ingroup rgba_utility_functions
*/
inline RGBA RGBAColor( double r, double g, double b )
{
return RGBAColor( RoundInt( 255*r ), RoundInt( 255*g ), RoundInt( 255*b ) );
}
/*!
* Returns an opaque RGBA pixel value for the specified separate color
* component real values.
*
* \param r Red color component
* \param g Green color component
* \param b Blue color component
*
* All components must be in the normalized range [0,1]. The returned RGBA
* value has its alpha component equal to 255 (opaque).
*
* \ingroup rgba_utility_functions
*/
inline RGBA RGBAColor( float r, float g, float b )
{
return RGBAColor( double( r ), double( g ), double( b ) );
}
/*!
* Returns an RGBA pixel value corresponding to a CSS color specification
* string.
*
* The string can be an hex-encoded color value in one of two valid formats:
*
* "#RRGGBB"
* "#RRGGBBAA"
*
* or a valid CSS color name like "white", "black", "red", "orange", and so on.
*
* CSS color names are case-insensitive, and are returned with their alpha
* components equal to 0xFF (opaque), except "transparent", which is returned
* as 0x00000000 (also known as "transparent black").
*
* If the string cannot be converted to a valid color value, this function
* silently ignores the error and returns zero.
*
* \ingroup rgba_utility_functions
*/
RGBA PCL_FUNC RGBAColor( const IsoString& colorNameOrHex );
inline RGBA RGBAColor( const IsoString::ustring_base& colorNameOrHex )
{
return RGBAColor( IsoString( colorNameOrHex ) );
}
/*!
* An alias to RGBAColor( const IsoString& ).
*
* \ingroup rgba_utility_functions
*/
inline RGBA StringToRGBAColor( const IsoString& colorNameOrHex )
{
return RGBAColor( colorNameOrHex );
}
inline RGBA StringToRGBAColor( const IsoString::ustring_base& colorNameOrHex )
{
return StringToRGBAColor( IsoString( colorNameOrHex ) );
}
/*!
* Returns an hex-encoded string representation of an RGBA pixel value,
* ignoring the alpha component.
*
* The returned string has the format "#RRGGBB".
*
* \ingroup rgba_utility_functions
*/
inline IsoString RGBColorToHexString( RGBA c )
{
IsoString s;
s.Format( "#%02X%02X%02X", Red( c ), Green( c ), Blue( c ) );
return s;
}
/*!
* Returns an hex-encoded string representation of an RGBA pixel value.
*
* The returned string has the format "#RRGGBBAA".
*
* \ingroup rgba_utility_functions
*/
inline IsoString RGBAColorToHexString( RGBA c )
{
IsoString s;
s.Format( "#%02X%02X%02X%02X", Red( c ), Green( c ), Blue( c ), Alpha( c ) );
return s;
}
/*!
* Returns the CSS color name corresponding to an RGBA pixel value.
*
* The alpha component is ignored, except for the special value 0x00000000,
* which is returned as "Transparent". If the value does not have a CSS named
* color counterpart, this function returns an empty string.
*
* \ingroup rgba_utility_functions
*/
IsoString PCL_FUNC CSSColorName( RGBA );
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_Color_h
// ----------------------------------------------------------------------------
// EOF pcl/Color.h - Released 2022-03-12T18:59:29Z
-269
View File
@@ -1,269 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/ColorComboBox.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_ColorComboBox_h
#define __PCL_ColorComboBox_h
/// \file pcl/ColorComboBox.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/AutoPointer.h>
#include <pcl/Color.h>
#include <pcl/ComboBox.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class ColorComboBox
* \brief A %ComboBox descendant class to select RGB colors.
*
* %ColorComboBox is a utility class that provides a simple list with the full
* set of CSS3 standard colors. This includes 143 %ComboBox items that are
* automatically shared by all existing %ColorComboBox instances. Thanks to
* this implicit sharing mechanism, a module can define a large number of
* %ColorComboBox controls without consuming too much resources on any
* supported platform.
*
* The list of items corresponding to CSS3 colors is sorted by \e hue value (in
* the HSV or HSI color ordering systems). This makes it much easier the task
* of selecting colors since similar hues are grouped visually.
*
* In addition to CSS3 standard colors, a single custom color item can be
* defined for a %ColorComboBox object. The custom color item is automatically
* managed by %ColorComboBox and appended to the end of standard items.
*
* \sa pcl/Color.h, ComboBox
*/
class PCL_CLASS ColorComboBox : public ComboBox
{
public:
/*!
* Constructs a %ColorComboBox as a child control of \a parent.
*
* A standard set of %ComboBox items is created for the full set of CSS3
* colors. This includes 143 color items.
*/
ColorComboBox( Control& parent = Control::Null() );
/*!
* Destroys a %ColorComboBox control.
*/
virtual ~ColorComboBox()
{
}
/*!
* Returns the RGB color value that corresponds to the currently selected
* %ComboBox item, or zero if no item is currently selected.
*
* \sa SetCurrentColor(), CustomColor(), HasCustomColor()
*/
RGBA CurrentColor() const;
/*!
* Selects a %ComboBox item corresponding to the specified \a color.
*
* If the specified \a color doesn't correspond to a standard CSS color, it
* replaces the existing <em>custom color item</em> in this %ColorComboBox,
* or a new one is created if there is no custom color item yet.
*
* \note The alpha (transparency) component of the specified \a color is
* always ignored. %ColorComboBox only includes opaque colors (alpha=0xff).
*
* \sa CurrentColor(), CustomColor(), HasCustomColor()
*/
void SetCurrentColor( RGBA color );
/*!
* Returns the current <em>custom color</em> in this %ColorComboBox, or zero
* if no custom color has been defined.
*
* To set a new custom color, call SetCurrentColor() with the desired custom
* color value.
*
* \sa HasCustomColor(), CurrentColor(), SetCurrentColor()
*/
RGBA CustomColor() const
{
return m_customColor;
}
/*!
* Returns true iff a <em>custom color item</em> has been defined in this
* %ColorComboBox control.
*
* This is a convenience member function, equivalent to:
* CustomColor() != 0.
*
* \sa CustomColor(), CurrentColor(), SetCurrentColor()
*/
bool HasCustomColor() const
{
return CustomColor() != 0;
}
// -------------------------------------------------------------------------
// Event handlers
//
// void OnColorSelected( ColorComboBox& sender, RGBA color );
// void OnColorHighlighted( ColorComboBox& sender, RGBA color );
// void OnCustomColorDefined( ColorComboBox& sender, RGBA color );
/*!
* \defgroup colorcombobox_event_handlers ColorComboBox Event Handlers
*/
/*!
* Defines the prototype of a <em>color combo box event handler</em>.
*
* A color combo box event is generated when an item is selected or
* highlighted in a color combo box, or when a new <em>custom color</em> has
* been defined.
*
* \param sender The %ColorComboBox control that sends a color combo box
* event.
*
* \param color The RGBA value of the color that has been selected or
* highlighted in the \a sender color combo box.
*
* \ingroup colorcombobox_event_handlers
*/
typedef void (Control::*color_event_handler)( ColorComboBox& sender, RGBA color );
/*!
* Sets the <em>color selected</em> event handler for this color combo box.
*
* \param handler The color combo box event handler. Must be a member
* function of the receiver object's class. This handler
* will be called whenever a color is selected in this
* color combo box control.
*
* \param receiver The control that will receive <em>color selected</em>
* events from this color combo box.
*
* \ingroup colorcombobox_event_handlers
*/
void OnColorSelected( color_event_handler handler, Control& receiver );
/*!
* Sets the <em>color highlighted</em> event handler for this color combo
* box control.
*
* \param handler The color combo box event handler. Must be a member
* function of the receiver object's class. This handler
* will be called whenever a color is highlighted in this
* color combo box control.
*
* \param receiver The control that will receive <em>color
* highlighted</em> events from this color combo box.
*
* \ingroup colorcombobox_event_handlers
*/
void OnColorHighlighted( color_event_handler handler, Control& receiver );
/*!
* Sets the <em>custom color defined</em> event handler for this color combo
* box control.
*
* \param handler The color combo box event handler. Must be a member
* function of the receiver object's class. This handler
* will be called whenever a new custom color is defined
* in this color combo box control.
*
* \param receiver The control that will receive <em>custom color
* defined</em> events from this color combo box.
*
* \ingroup colorcombobox_event_handlers
*/
void OnCustomColorDefined( color_event_handler handler, Control& receiver );
private:
struct EventHandlers
{
color_event_handler onColorSelected = nullptr;
Control* onColorSelectedReceiver = nullptr;
color_event_handler onColorHighlighted = nullptr;
Control* onColorHighlightedReceiver = nullptr;
color_event_handler onCustomColorDefined = nullptr;
Control* onCustomColorDefinedReceiver = nullptr;
EventHandlers() = default;
EventHandlers( const EventHandlers& ) = default;
EventHandlers& operator =( const EventHandlers& ) = default;
};
AutoPointer<EventHandlers> m_handlers;
RGBA m_customColor;
void ItemSelected( ComboBox&, int );
void ItemHighlighted( ComboBox&, int );
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
#endif // __PCL_ColorComboBox_h
// ----------------------------------------------------------------------------
// EOF pcl/ColorComboBox.h - Released 2022-03-12T18:59:29Z
-196
View File
@@ -1,196 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/ColorDialog.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_ColorDialog_h
#define __PCL_ColorDialog_h
/// \file pcl/ColorDialog.h
#include <pcl/Defs.h>
#include <pcl/Color.h>
#include <pcl/Dialog.h>
#include <pcl/NumericControl.h>
#include <pcl/PushButton.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*
* ### TODO: Implement a fully-functional color dialog box in PCL.
*/
// ----------------------------------------------------------------------------
class PCL_INTERNAL SimpleColorDialogPrivate;
/*!
* \class SimpleColorDialog
* \brief A simple color selection dialog
*
* %SimpleColorDialog is a simplified color selection dialog box. This class is
* suitable to implement quick definition of 32-bit RGBA color items as part of
* a user preferences definition interface. It implements optional support for
* an alpha (transparency) component. Color components are specified in the
* eight-bit range [0,255].
*
* \sa Dialog
*/
class PCL_CLASS SimpleColorDialog : public Dialog
{
public:
enum
{
AlphaEnabled = 0x0080, //!< Enable definition of the alpha (transparency) component.
Grayscale = 0x0020 //!< Define a grayscale AARRGGBB color, where RR=GG=BB.
};
/*!
* Constructs a %SimpleColorDialog object.
*
* \param color Address of a 32-bit unsigned integer variable (a RGBA
* color value). If a non-null pointer is specified, when the
* user accepts the dialog the selected color value will be
* written to the specified variable.
*
* \param flags A combination of flags that define the behavior of the
* color selection dialog. Currently the following flags are
* supported:\n
* \n
* SimpleColorDialog::AlphaEnabled: Enable definition of the
* alpha (transparency) component\n
* \n
* SimpleColorDialog::Grayscale: Define a grayscale AARRGGBB
* color, where RR=GG=BB.
*/
SimpleColorDialog( RGBA* color = nullptr, uint32 flags = 0 );
/*!
* Destroys a %SimpleColorDialog object.
*/
virtual ~SimpleColorDialog()
{
}
/*!
* Sets the current RGBA color value.
*
* This function can be called before executing the dialog to set an initial
* color value, as an alternative to passing a non-null pointer to the
* constructor.
*/
void SetColor( RGBA color );
/*!
* Returns the RGBA color value that has been defined by the user.
*
* If a non-null pointer was passed to the constructor, this function
* returns the same color value that will be (or has been) written to the
* corresponding variable.
*/
RGBA Color() const
{
return m_workingColor;
}
/*!
* Returns true iff this dialog allows definition of an alpha (transparency)
* color component.
*/
bool IsAlphaEnabled() const
{
return (m_flags & AlphaEnabled) != 0;
}
/*!
* Returns true iff this dialog defines a grayscale color, where the three
* individual RGB components are equal.
*/
bool IsGrayscale() const
{
return (m_flags & Grayscale) != 0;
}
protected:
RGBA* m_color;
RGBA m_workingColor;
uint32 m_flags;
VerticalSizer Global_Sizer;
HorizontalSizer Color_Sizer;
VerticalSizer Sliders_Sizer;
NumericControl V0_NumericControl;
NumericControl V1_NumericControl;
NumericControl V2_NumericControl;
NumericControl V3_NumericControl;
Control ColorSample_Control;
HorizontalSizer Buttons_Sizer;
PushButton OK_PushButton;
PushButton Cancel_PushButton;
void Color_ValueUpdated( NumericEdit& sender, double value );
void ColorSample_Paint( Control& sender, const Rect& updateRect );
void Done_Click( Button& sender, bool checked );
void Dialog_Return( Dialog& sender, int retVal );
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_ColorDialog_h
// ----------------------------------------------------------------------------
// EOF pcl/ColorDialog.h - Released 2022-03-12T18:59:29Z
-348
View File
@@ -1,348 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/ColorFilterArray.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_ColorFilterArray_h
#define __PCL_ColorFilterArray_h
/// \file pcl/ColorFilterArray.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/Exception.h>
#include <pcl/String.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \defgroup cfa_classes Color Filter Array (CFA) Descriptive Classes
*/
/*!
* \class ColorFilterArray
* \brief Color filter array (CFA) structure.
*
* %ColorFilterArray describes a color filter array (CFA), such as one of the
* Bayer filters typically used in raw digital camera images.
*
* \ingroup cfa_classes
* \sa BayerFilterBGGR, BayerFilterGBRG, BayerFilterGRBG, BayerFilterRGGB
*/
class PCL_CLASS ColorFilterArray
{
public:
/*!
* Constructs a %ColorFilterArray object.
*
* \param pattern A sequence of ASCII characters defining a CFA matrix.
* Each string character represents an element of the CFA
* matrix, which can be one of:\n
* \n
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>0</td> <td>A nonexistent or undefined CFA element.</td></tr>
* <tr><td>R</td> <td>Red</td></tr>
* <tr><td>G</td> <td>Green</td></tr>
* <tr><td>B</td> <td>Blue</td></tr>
* <tr><td>W</td> <td>White or panchromatic</td></tr>
* <tr><td>C</td> <td>Cyan</td></tr>
* <tr><td>M</td> <td>Magenta</td></tr>
* <tr><td>Y</td> <td>Yellow</td></tr>
* </table>\n
* \n
* The length of this string must be equal to the product
* of \a width by \a height. Otherwise an Error exception
* will be thrown. An exception will also be thrown if one
* or more invalid CFA elements are found in \a pattern.
*
* \param width Horizontal dimension of the CFA matrix in pixels.
*
* \param height Vertical dimension of the CFA matrix in pixels.
*
* \param name An optional string identifying the type or model of CFA
* that is being described by this object.
*/
ColorFilterArray( const IsoString& pattern, int width, int height, const String& name = String() )
: m_pattern( pattern.Uppercase() )
, m_width( width )
, m_height( height )
, m_name( name )
{
if ( m_width < 1 || m_height < 1 || size_type( NumberOfElements() ) != m_pattern.Length() )
throw Error( "Malformed CFA pattern" );
for ( auto element : m_pattern )
if ( !IsValidCFAElement( element ) )
throw Error( "Invalid CFA pattern \'" + m_pattern + "\'" );
}
/*!
* Constructs an empty %ColorFilterArray object. An empty CFA has no pattern
* and zero dimensions.
*/
ColorFilterArray() = default;
/*!
* Copy constructor.
*/
ColorFilterArray( const ColorFilterArray& ) = default;
/*!
* Move constructor.
*/
ColorFilterArray( ColorFilterArray&& ) = default;
/*!
* Copy assignment operator.
*/
ColorFilterArray& operator =( const ColorFilterArray& ) = default;
/*!
* Move assignment operator.
*/
ColorFilterArray& operator =( ColorFilterArray&& ) = default;
/*!
* Returns a reference to the CFA pattern in this object.
*/
const IsoString& Pattern() const
{
return m_pattern;
}
/*!
* Returns the horizontal dimension of this CFA structure in pixels.
*/
int Width() const
{
return m_width;
}
/*!
* Returns the vertical dimension of this CFA structure in pixels.
*/
int Height() const
{
return m_height;
}
/*!
* Returns the total number of elements (or pixels) in this CFA structure.
*/
int NumberOfElements() const
{
return int( m_pattern.Length() );
}
/*!
* Returns true only if this is an empty %ColorFilterArray object. An empty
* CFA has no pattern and zero dimensions.
*/
bool IsEmpty() const
{
return m_pattern.IsEmpty();
}
/*!
* Returns a reference to the name of this CFA structure.
*/
const String& Name() const
{
return m_name;
}
/*!
* Returns true only if this object describes an RGB Bayer filter: BGGR,
* GRBG, GBRG, or RGGB.
*/
bool IsBayerFilter() const
{
return m_pattern == "BGGR" || m_pattern == "GRBG" || m_pattern == "GBRG" || m_pattern == "RGGB";
}
/*!
* Returns a copy of the CFA element at the specified \a x and \a y
* coordinates (pixel column and row, respectively). The top-left corner of
* the CFA is by convention located at coordinates x=y=0.
*
* For a description of valid CFA elements, see the class constructor.
*/
char Element( int x, int y ) const
{
size_type i = y*m_width + x;
if ( i < m_pattern.Length() )
return m_pattern[i];
return '\0';
}
/*
* Clears all internal structures to yield an empty CFA.
*/
void Clear()
{
m_pattern.Clear();
m_width = m_height = 0;
m_name.Clear();
}
/*!
* Returns true iff this object represents the same CFA structure as another
* object \a x. This operator ignores the Name() components of both objects.
*/
bool operator ==( const ColorFilterArray& x ) const
{
return m_pattern == x.m_pattern && m_width == x.m_width && m_height == x.m_height;
}
/*!
* Returns true only if this %ColorFilterArray object precedes another
* object \a x. This is a lexicographic comparison performed exclusively on
* the CFA patterns, ignoring matrix dimensions and filter names.
*/
bool operator <( const ColorFilterArray& x ) const
{
return m_pattern < x.m_pattern;
}
/*!
* Returns true only if the specified character is a valid element of a CFA
* pattern specification. For a description of valid CFA elements, see the
* class constructor.
*/
static bool IsValidCFAElement( char element )
{
return strchr( "0RGBWCMY", element ) != nullptr;
}
private:
IsoString m_pattern;
int m_width = 0;
int m_height = 0;
String m_name;
};
// ----------------------------------------------------------------------------
/*!
* \class BayerFilterRGGB
* \brief RGGB Bayer filter representation.
* \ingroup cfa_classes
* \sa ColorFilterArray, BayerFilterBGGR, BayerFilterGBRG, BayerFilterGRBG
*/
class PCL_CLASS BayerFilterRGGB : public ColorFilterArray
{
public:
BayerFilterRGGB()
: ColorFilterArray( "RGGB", 2, 2, "RGGB Bayer Filter" )
{
}
};
/*!
* \class BayerFilterBGGR
* \brief BGGR Bayer filter representation.
* \ingroup cfa_classes
* \sa ColorFilterArray, BayerFilterGBRG, BayerFilterGRBG, BayerFilterRGGB
*/
class PCL_CLASS BayerFilterBGGR : public ColorFilterArray
{
public:
BayerFilterBGGR()
: ColorFilterArray( "BGGR", 2, 2, "BGGR Bayer Filter" )
{
}
};
/*!
* \class BayerFilterGBRG
* \brief GBRG Bayer filter representation.
* \ingroup cfa_classes
* \sa ColorFilterArray, BayerFilterBGGR, BayerFilterGRBG, BayerFilterRGGB
*/
class PCL_CLASS BayerFilterGBRG : public ColorFilterArray
{
public:
BayerFilterGBRG()
: ColorFilterArray( "GBRG", 2, 2, "GBRG Bayer Filter" )
{
}
};
/*!
* \class BayerFilterGRBG
* \brief GRBG Bayer filter representation.
* \ingroup cfa_classes
* \sa ColorFilterArray, BayerFilterBGGR, BayerFilterGBRG, BayerFilterRGGB
*/
class PCL_CLASS BayerFilterGRBG : public ColorFilterArray
{
public:
BayerFilterGRBG()
: ColorFilterArray( "GRBG", 2, 2, "GRBG Bayer Filter" )
{
}
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_ColorFilterArray_h
// ----------------------------------------------------------------------------
// EOF pcl/ColorFilterArray.h - Released 2022-03-12T18:59:29Z
-133
View File
@@ -1,133 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/ColorSpace.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_ColorSpace_h
#define __PCL_ColorSpace_h
/// \file pcl/ColorSpace.h
#include <pcl/Defs.h>
#include <pcl/String.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::ColorSpace
* \brief Supported color spaces
*
* Current versions of the PixInsight platform support the following color
* spaces for images:
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>ColorSpace::Unknown</td> <td>Corresponds to an unknown or unsupported color space</td></tr>
* <tr><td>ColorSpace::Gray</td> <td>Grayscale monochrome space</td></tr>
* <tr><td>ColorSpace::RGB</td> <td>RGB color space</td></tr>
* <tr><td>ColorSpace::CIEXYZ</td> <td>CIE XYZ color space</td></tr>
* <tr><td>ColorSpace::CIELab</td> <td>CIE L*a*b* color space</td></tr>
* <tr><td>ColorSpace::CIELch</td> <td>CIE L*c*h* color space</td></tr>
* <tr><td>ColorSpace::HSV</td> <td>HSV color space: Hue, Saturation, Value</td></tr>
* <tr><td>ColorSpace::HSI</td> <td>HSI color space: Hue, Saturation, Intensity</td></tr>
* </table>
*/
namespace ColorSpace
{
enum value_type
{
Unknown = -1, // Corresponds to an unknown or unsupported color space
Gray = 0, // Grayscale monochrome space
RGB, // RGB color space
CIEXYZ, // CIE XYZ color space
CIELab, // CIE L*a*b* color space
CIELch, // CIE L*c*h* color space
HSV, // HSV color space: Hue, Saturation, Value
HSI, // HSI color space: Hue, Saturation, Intensity
NumberOfColorSpaces
};
/*!
* Returns the number of nominal channels in the specified color space.
*/
inline int NumberOfNominalChannels( int colorSpace )
{
return (colorSpace == Gray) ? 1 : 3;
}
/*!
* Returns a string representing the name of a color space.
*
* \param colorSpace A supported color space, identified by its
* corresponding symbolic constant.
*/
String Name( int colorSpace );
/*!
* Returns the identifier of a nominal channel in a specified color space.
*
* \param colorSpace A supported color space, identified by its
* corresponding symbolic constant.
*
* \param channel The index >= 0 of a nominal channel or component.
*/
String ChannelId( int colorSpace, int channel );
}
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_ColorSpace_h
// ----------------------------------------------------------------------------
// EOF pcl/ColorSpace.h - Released 2022-03-12T18:59:29Z
-567
View File
@@ -1,567 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/ComboBox.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_ComboBox_h
#define __PCL_ComboBox_h
/// \file pcl/ComboBox.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/AutoPointer.h>
#include <pcl/Bitmap.h>
#include <pcl/Control.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class ComboBox
* \brief Client-side interface to a PixInsight %ComboBox control
*
* ### TODO: Write a detailed description for %ComboBox
*/
class PCL_CLASS ComboBox : public Control
{
public:
/*!
* Constructs a %ComboBox as a child control of \a parent.
*/
ComboBox( Control& parent = Control::Null() );
/*!
* Destroys a %ComboBox control.
*/
virtual ~ComboBox()
{
}
/*!
* Returns the total number of items in this %ComboBox control.
*/
int NumberOfItems() const;
/*!
* Returns the index of the current item in this combo box, or -1 if no item
* is currently selected in this combo box.
*/
int CurrentItem() const;
/*!
* Selects a combo box item with the specified \a index.
*/
void SetCurrentItem( int index );
/*!
* Finds an item in this combo box. Returns the index of the item found, or
* -1 if no item was found that matches the specified criteria.
*
* \param text Text to find.
*
* \param fromIdx Starting index from which the search will begin.
*
* \param exactMatch Whether the search will succeed only if an exact
* match is found, or a partial match is sufficient.
*
* \param caseSensitive True for a case-sensitive search.
*/
int FindItem( const String& text, int fromIdx = 0, bool exactMatch = false, bool caseSensitive = false ) const;
/*!
* Inserts a new item in this combo box.
*
* \param index Insertion point. If an index greater than or equal to the
* current length is specified, the new item is appended to
* the end of the current set of items. If the index is less
* than or equal to zero, the new item will be prepended to
* the current list of items.
*
* \param text Text for the new item.
*
* \param icon Item icon.
*/
void InsertItem( int index, const String& text, const Bitmap& icon = Bitmap::Null() );
/*!
* Adds a new item at the end of this combo box.
*
* This is a convenience function, equivalent to:
* InsertItem( NumberOfItems(), text, icon )
*/
void AddItem( const String& text, const Bitmap& icon = Bitmap::Null() )
{
InsertItem( NumberOfItems(), text, icon );
}
/*!
* Inserts a list of combo box items.
*
* \param index Insertion point. If an index greater than or equal to the
* current length is specified, the new items are appended to
* the end of the current set of items. If the index is less
* than or equal to zero, the new items will be prepended to
* the current list of items.
*
* \param i,j Two forward iterators defining a range of contiguous
* strings that correspond to the texts of the newly created
* items.
*/
template <class FI>
void InsertItems( int index, FI i, FI j )
{
if ( i != j )
{
DisableUpdates();
do
InsertItem( index++, *i );
while ( ++i != j );
EnableUpdates();
Update();
}
}
/*!
* Appends a list of combo box items.
*
* This is a convenience function, equivalent to:
* InsertItems( NumberOfItems(), i, j )
*/
template <class FI>
void AddItems( FI i, FI j )
{
InsertItems( NumberOfItems(), i, j );
}
/*!
* Inserts a list of combo box items from a container.
*
* \param index Insertion point. If an index greater than or equal to the
* current length is specified, the new items are appended to
* the end of the current set of items. If the index is less
* than or equal to zero, the new items will be prepended to
* the current list of items.
*
* \param c A reference to a container with the list of strings that
* will be assigned to newly created items.
*
* This is a convenience function, equivalent to:
* InsertItems( index, c.Begin(), c.End() )
*/
template <class C>
void InsertItems( int index, const C& c )
{
InsertItems( index, c.Begin(), c.End() );
}
/*!
* Appends a list of combo box items from a container.
*
* \param c A reference to a container with the list of strings that will
* be used for newly created items.
*
* This is a convenience function, equivalent to:
* InsertItems( NumberOfItems(), c );
*/
template <class C>
void AddItems( const C& c )
{
InsertItems( NumberOfItems(), c );
}
/*!
* Removes the item at the specified \a index. If the specified index is
* greater than or equal to the current length, or less than zero,, no items
* are removed.
*/
void RemoveItem( int index );
/*!
* Removes all existing items in this combo box.
*/
void Clear();
/*!
* Returns the current text of the combo box item at the specified \a index.
*/
String ItemText( int index ) const;
/*!
* Sets the current text of the combo box item at the specified \a index.
*/
void SetItemText( int index, const String& );
/*!
* Empties the text of the combo box item at the specified \a index.
*/
void ClearItemText( int index )
{
SetItemText( index, String() );
}
/*!
* Returns the current icon of the combo box item at the specified \a index.
*/
Bitmap ItemIcon( int index ) const;
/*!
* Changes the icon of the combo box item at the specified \a index. If a
* null bitmap is specified, the combo box item will have no associated icon.
*/
void SetItemIcon( int index, const Bitmap& );
/*!
* Clears the icon of the combo box item at the specified \a index.
*
* This is a convenience function, equivalent to:
* SetItemIcon( index, Bitmap::Null() )
*/
void ClearItemIcon( int index )
{
SetItemIcon( index, Bitmap::Null() );
}
/*!
* Returns true iff this combo box is editable. Editable combo boxes allow
* the user to edit the text of the currently selected item.
*/
bool IsEditEnabled() const;
/*!
* Enables or disables the editable state of this combo box control.
*/
void EnableEdit( bool = true );
/*!
* Disables or enables the editable state of this combo box control.
*
* This is a convenience function, equivalent to:
* EnableEdit( !disable )
*/
void DisableEdit( bool disable = true )
{
EnableEdit( !disable );
}
/*!
* Returns the current text of the editable part of this combo box control.
*/
String EditText() const;
/*!
* Sets the text contents of the editable part of this combo box control.
*/
void SetEditText( const String& );
/*!
* Empties the editable part of this combo box control.
*/
void ClearEditText()
{
SetEditText( String() );
}
/*!
* Returns true iff auto completion is currently enabled for this combo box
* control.
*/
bool IsAutoCompletionEnabled() const;
/*!
* Enables or disables auto completion for this combo box control.
*/
void EnableAutoCompletion( bool = true );
/*!
* Disables or enables auto completion for this combo box control.
*
* This is a convenience function, equivalent to:
* EnableAutoCompletion( !disable )
*/
void DisableAutoCompletion( bool disable = true )
{
EnableAutoCompletion( !disable );
}
/*!
* Provides the current icon dimensions for this combo box control.
*
* \param[out] width,height Icon dimensions in pixels.
*/
void GetIconSize( int& width, int& height ) const;
/*!
* Returns the current icon width in pixels for this combo box control.
*/
int IconWidth() const
{
int w, dum; GetIconSize( w, dum ); return w;
}
/*!
* Returns the current icon height in pixels for this combo box control.
*/
int IconHeight() const
{
int dum, h; GetIconSize( dum, h ); return h;
}
/*!
* Sets the icon dimensions in pixels for this combo box control.
*/
void SetIconSize( int width, int height );
/*!
* Sets the icon size in pixels for this combo box control.
*
* This is a convenience function, equivalent to:
* SetIconSize( size, size )
*/
void SetIconSize( int size )
{
SetIconSize( size, size );
}
/*! #
*/
void GetScaledIconSize( int& width, int& height ) const
{
GetIconSize( width, height ); width = PhysicalPixelsToLogical( width ); height = PhysicalPixelsToLogical( height );
}
/*! #
*/
int ScaledIconWidth() const
{
int width, dum; GetIconSize( width, dum ); return PhysicalPixelsToLogical( width );
}
/*! #
*/
int ScaledIconHeight() const
{
int dum, height; GetIconSize( dum, height ); return PhysicalPixelsToLogical( height );
}
/*! #
*/
void SetScaledIconSize( int width, int height )
{
SetIconSize( LogicalPixelsToPhysical( width ), LogicalPixelsToPhysical( height ) );
}
/*! #
*/
void SetScaledIconSize( int size )
{
size = LogicalPixelsToPhysical( size );
SetIconSize( size, size );
}
/*!
* Returns the maximum number of items that can be visible when this combo
* box control is dropped down, or 0 is no specific limit has been set.
*/
int MaxVisibleItemCount() const;
/*!
* Sets the maximum number of items that can be visible when this combo
* box control is dropped down. If zero is specified, the combo box control
* will show a convenient number of items automatically in drop-down state.
*/
void SetMaxVisibleItemCount( int );
/*!
* Returns the minimum number of characters that fit in this combo box
* control, or zero if no specific limit has been set.
*/
int MinItemCharWidth() const;
/*!
* Sets the minimum number of characters that must fit in this combo box
* control. If zero is specified, the combo box control will adapt its
* size automatically to its initial contents.
*/
void SetMinItemCharWidth( int );
//
// Drop-down items list
//
/*!
* Forces this combo box control to enter the drop-down state. The list of
* existing items is shown on a pop-up panel where they can be browsed and
* selected.
*/
void ShowList();
/*!
* Forces this combo box control to exit the drop-down state. The list of
* items will be hidden, if it is currently visible.
*/
void HideList();
// -------------------------------------------------------------------------
// Event handlers
//
// void OnItemSelected( ComboBox& sender, int itemIndex );
// void OnItemHighlighted( ComboBox& sender, int itemIndex );
// void OnEditTextUpdated( ComboBox& sender );
/*!
* \defgroup combobox_event_handlers ComboBox Event Handlers
*/
/*!
* Defines the prototype of a <em>combo box item event handler</em>.
*
* A combo box item event is generated when an item is selected or
* highlighted in a combo box.
*
* \param sender The ComboBox control that sends a combo box item event.
*
* \param itemIndex The index of the combo box item where the event
* originated, in the range from zero to the number of
* existing combo box items minus one.
*
* \ingroup combobox_event_handlers
*/
typedef void (Control::*item_event_handler)( ComboBox& sender, int itemIndex );
/*!
* Defines the prototype of a <em>combo box edit event handler</em>.
*
* A combo box edit event is generated when the text in the editable part of
* a combo box is changed by the user.
*
* \param sender The ComboBox control that sends a combo box edit event.
*
* \ingroup combobox_event_handlers
*/
typedef void (Control::*edit_event_handler)( ComboBox& sender );
/*!
* Sets the <em>item selected</em> event handler for this combo box.
*
* \param handler The combo box item event handler. Must be a member
* function of the receiver object's class. This handler
* will be called whenever an item is selected in this
* combo box control.
*
* \param receiver The control that will receive <em>item selected</em>
* events from this combo box.
*
* \ingroup combobox_event_handlers
*/
void OnItemSelected( item_event_handler handler, Control& receiver );
/*!
* Sets the <em>item highlighted</em> event handler for this combo box.
*
* \param handler The combo box item event handler. Must be a member
* function of the receiver object's class. This handler
* will be called whenever an item is highlighted in this
* combo box control.
*
* \param receiver The control that will receive <em>item highlighted</em>
* events from this combo box.
*
* \ingroup combobox_event_handlers
*/
void OnItemHighlighted( item_event_handler handler, Control& receiver );
/*!
* Sets the <em>edit updated</em> event handler for this combo box.
*
* \param handler The combo box edit event handler. Must be a member
* function of the receiver object's class. This handler
* will be called whenever the text changes in the
* editable part of combo box control.
*
* \param receiver The control that will receive <em>edit updated</em>
* events from this combo box.
*
* \ingroup combobox_event_handlers
*/
void OnEditTextUpdated( edit_event_handler handler, Control& receiver );
private:
struct EventHandlers
{
item_event_handler onItemSelected = nullptr;
item_event_handler onItemHighlighted = nullptr;
edit_event_handler onEditTextUpdated = nullptr;
EventHandlers() = default;
EventHandlers( const EventHandlers& ) = default;
EventHandlers& operator =( const EventHandlers& ) = default;
};
AutoPointer<EventHandlers> m_handlers;
friend class ComboBoxEventDispatcher;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
#endif // __PCL_ComboBox_h
// ----------------------------------------------------------------------------
// EOF pcl/ComboBox.h - Released 2022-03-12T18:59:29Z
-1110
View File
File diff suppressed because it is too large Load Diff
-809
View File
@@ -1,809 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Compression.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Compression_h
#define __PCL_Compression_h
/// \file pcl/Compression.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/ByteArray.h>
#include <pcl/ParallelProcess.h>
#include <pcl/String.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \defgroup compression_classes Data Compression Classes
*/
/*!
* \class Compression
* \brief Abstract base class of data compression algorithm implementations.
*
* %Compression defines a common interface for compression algorithms such as
* Zlib/deflate, LZ4, LZMA, etc.
*
* \ingroup compression_classes
* \sa ZLibCompression, LZ4Compression, LZ4HCCompression, BloscLZCompression
*/
class PCL_CLASS Compression : public ParallelProcess
{
public:
/*!
* \struct pcl::Compression::Subblock
* \brief Compression subblock data.
*/
struct Subblock
{
ByteArray compressedData; //!< Sub-block compressed data.
size_type uncompressedSize = 0; //!< size in bytes of the uncompressed subblock.
uint64 checksum = 0; //!< If non-zero, 64-bit non-cryptographic checksum of the compressed data.
};
/*!
* \struct pcl::Compression::Performance
* \brief Compression/decompression performance measurements.
*/
struct Performance
{
float sizeReduction = 0; //!< Relative size reduction, e.g.: 0.25 for a 25% size reduction.
double throughput = 0; //!< Compression/decompression rate in MiB per second.
int numberOfThreads = 0; //!< Number of parallel threads used.
};
/*!
* A dynamic, ordered list of compression subblocks.
*/
typedef Array<Subblock> subblock_list;
/*!
* Default constructor. This object will be initialized with the following
* parameters:
*
* \li Compression level: Use an algorithm-dependent default level to
* achieve a good compromise between running speed and compression ratio.
*
* \li Byte shuffling: Enabled.
*
* \li Item size: One byte (which inhibits shuffling).
*
* \li Sub-block checksums: Enabled.
*
* \li Sub-block size: Use the maximum possible subblock size for each
* compression algorithm.
*
* \li Parallel processing: Enabled to use the maximum possible number of
* processors.
*/
Compression() = default;
/*!
* Copy constructor.
*/
Compression( const Compression& ) = default;
/*!
* Copy assignment operator. Returns a reference to this object.
*/
Compression& operator =( const Compression& ) = default;
/*!
* Virtual destructor.
*/
virtual ~Compression()
{
}
/*!
* Returns the name of this data compression algorithm.
*/
virtual String AlgorithmName() const = 0;
/*!
* Returns the maximum compression optimization level supported by this
* algorithm. Higher levels tend to provide higher compression ratios at the
* cost of more computational work.
*/
virtual int MaxCompressionLevel() const = 0;
/*!
* Returns the default compression optimization level for this algorithm.
* The returned value represents a good compromise between execution speed
* and compression ratio.
*/
virtual int DefaultCompressionLevel() const = 0;
/*!
* Returns the current compression optimization level.
*
* See SetCompressionLevel() for more information.
*/
int CompressionLevel() const
{
return m_compressionLevel;
}
/*!
* Sets an algorithm-dependent compression optimization level.
*
* Higher levels tend to provide higher compression ratios at the cost of
* more computational work. If zero or a negative value is specified, the
* compression routines will select a default level automatically to achieve
* a good compromise between speed and compression ratio for each
* compression algorithm.
*/
void SetCompressionLevel( int level )
{
m_compressionLevel = Range( level, 0, MaxCompressionLevel() );
}
/*!
* Sets the default compression optimization level for this compression
* algorithm.
*
* This function is a shortcut for SetCompressionLevel( 0 ). The default
* compression level attempts to achieve a good compromise between speed and
* compression ratio for each compression algorithm.
*/
void SetDefaultCompressionLevel()
{
SetCompressionLevel( 0 );
}
/*!
* Returns true iff byte shuffling is currently enabled for this
* %Compression object.
*
* See EnableByteShuffling() for more information.
*/
bool ByteShufflingEnabled() const
{
return m_byteShuffle;
}
/*!
* Enables byte shuffling for this %Compression object.
*
* Enable this option to pre-process the data with a byte shuffling routine
* before compression. The byte shuffle algorithm reorganizes the data in a
* clever way that can greatly improve compression ratios, especially for
* data with high \e locality (or data containing similar values close
* together), such as most scientific and observational data. This option
* can be particularly efficient for compression of data structured as
* contiguous sequences of 16-bit, 32-bit and 64-bit numbers, such as most
* images processed with PixInsight. For 8-bit data, byte shuffling is a
* no-op and is hence ignored. Byte shuffling is enabled by default.
*/
void EnableByteShuffling( bool enable = true )
{
m_byteShuffle = enable;
}
/*!
* Disables byte shuffling for this %Compression object.
*
* Equivalent to EnableByteShuffling( !disable ).
*/
void DisableByteShuffling( bool disable = true )
{
EnableByteShuffling( !disable );
}
/*!
* Returns the current item size for shuffling.
*
* This is the length in bytes of an element in the uncompressed data, used
* by the byte shuffling algorithm. See EnableByteShuffling() for more
* information.
*/
size_type ItemSize() const
{
return m_itemSize;
}
/*!
* Sets the item size for shuffling.
*
* \a itemSize is the length in bytes of a data item for the byte shuffling
* algorithm. See EnableByteShuffling() for more information.
*/
void SetItemSize( size_type itemSize )
{
m_itemSize = uint8( Range( itemSize, size_type( 1 ), size_type( 128 ) ) );
}
/*!
* Returns the current compression subblock size in bytes.
*
* See SetSubblockSize() for more information.
*/
size_type SubblockSize() const
{
return m_subblockSize;
}
/*!
* Sets the compression subblock size.
*
* The specified \a size is the length in bytes of a compression subblock.
* If a value of zero is specified, the effective block size will be the
* maximum possible for this compression algorithm (for example, slightly
* less than 4 GiB for zlib/deflate and slightly less than 2 GiB for LZ4 and
* BloscLZ). The number of elements in the arrays returned by the Compress()
* family of functions will depend on this value.
*/
void SetSubblockSize( size_type size )
{
m_subblockSize = Range( size, size_type( 0 ), MaxBlockSize() );
}
/*!
* Returns true iff subblock checksums are currently enabled for this
* %Compression object.
*
* See EnableChecksums() for more information.
*/
bool ChecksumsEnabled() const
{
return m_checksums;
}
/*!
* Enables subblock checksums for this %Compression object.
*
* When this option is enabled, a non-cryptographic checksum is computed for
* each compressed subblock and stored along with the subblock data. These
* checksums are computed again before decompression and compared with the
* stored values. This guarantees that the compressed data have not been
* altered.
*
* In current versions of PixInsight, the xxHash algorithm (64-bit version)
* is used for compressed subblock checksums. xxHash is an extremely fast
* hashing function, so its impact on compression/decompression speed is
* negligible. See the pcl::Hash64() function for details.
*/
void EnableChecksums( bool enable = true )
{
m_checksums = enable;
}
/*!
* Disables subblock checksums for this %Compression object.
*
* Equivalent to EnableChecksums( !disable ).
*/
void DisableChecksums( bool disable = true )
{
EnableChecksums( !disable );
}
/*!
* Compresses a data block.
*
* \param data Starting address of the data block to be compressed.
*
* \param size Length in bytes of the data block to be compressed.
*
* \param perf If non-null, pointer to a Performance structure where
* performance data will be provided.
*
* Returns a dynamic array of compressed subblocks. Each array element is a
* Subblock structure with the compressed data, the uncompressed length in
* bytes, and an optional checksum. If compression succeeds, the returned
* array will have at least one element.
*
* If the specified \a size is zero, or if one or more subblocks are not
* compressible with this algorithm, this function returns an empty array.
*
* This function can only throw an exception if the specified \a data
* pointer is null, or in the event of an out-of-memory condition.
*/
subblock_list Compress( const void* data, size_type size, Performance* perf = nullptr ) const;
/*!
* Compression of a direct container with contiguous storage.
*
* \param data Reference to a direct container with contiguous storage
* and PCL container semantics. Meaningful Begin() and Size()
* member functions are required. Typically, the ByteArray
* class is used, although any array-like direct container
* class is appropriate, including Array, String, Vector and
* Matrix, among others.
*
* \param perf If non-null, pointer to a Performance structure where
* performance data will be provided.
*
* Returns a dynamic array of compressed subblocks. Each array element is a
* Subblock structure with the compressed data, the uncompressed length in
* bytes, and an optional checksum. If compression succeeds, the returned
* array will have at least one element.
*
* If the specified container is empty, or if one or more subblocks are not
* compressible with this algorithm, this function returns an empty array.
*
* This function can only throw an exception in the event of an
* out-of-memory condition.
*/
template <class C>
subblock_list Compress( const C& data, Performance* perf = nullptr ) const
{
return Compress( data.Begin(), data.Size(), perf );
}
/*!
* Decompression of a set of compressed subblocks.
*
* \param data Starting address of the output uncompressed data block.
*
* \param maxSize Maximum space in bytes available at \a data. Must be
* equal to or larger than the total uncompressed size.
*
* \param subblocks Reference to a dynamic array of compressed subblocks.
* The specified array should be the result of a previous
* call to one of the Compress() functions for this
* algorithm. This object must have coherent ItemSize()
* and ByteShufflingEnabled() properties to match the ones
* used when the data was compressed.
*
* \param perf If non-null, pointer to a Performance structure where
* performance data will be provided.
*
* Upon successful completion, the uncompressed data will be available in
* the specified output \a data block, and the function will return the
* length in bytes of the uncompressed data (necessarily smaller than or
* equal to \a maxSize).
*
* In the event of errors, such as invalid or corrupted data, uncompressed
* block or subblock size mismatch, or an out-of-memory condition, this
* function throws an Error exception. In such case the data possibly stored
* in the output \a data buffer will be invalid.
*/
size_type Uncompress( void* data, size_type maxSize,
const subblock_list& subblocks, Performance* perf = nullptr ) const;
/*!
* Decompression of a set of compressed subblocks.
*
* \param subblocks Reference to a dynamic array of compressed subblocks.
* The specified array should be the result of a previous
* call to one of the Compress() functions for this
* algorithm. This object must have coherent ItemSize()
* and ByteShufflingEnabled() properties to match the ones
* used when the data was compressed.
*
* \param perf If non-null, pointer to a Performance structure where
* performance data will be provided.
*
* Returns the uncompressed data as a ByteArray object.
*
* In the event of errors, such as invalid or corrupted data, uncompressed
* block or subblock size mismatch, or an out-of-memory condition, this
* function throws an Error exception.
*/
ByteArray Uncompress( const subblock_list& subblocks, Performance* perf = nullptr ) const
{
size_type uncompressedSize = 0;
for ( const Subblock& subblock : subblocks )
uncompressedSize += subblock.uncompressedSize;
ByteArray data( uncompressedSize );
(void)Uncompress( data.Begin(), uncompressedSize, subblocks, perf );
return data;
}
/*!
* Decompression of a compressed data block stored in a ByteArray object.
* Returns the uncompressed data as a ByteArray.
*
* See the Uncompress( const subblock_list&, Performance* ) const member
* function for more information.
*/
ByteArray Uncompress( const ByteArray& compressedData,
size_type uncompressedSize, Performance* perf = nullptr ) const
{
Subblock subblock;
subblock.compressedData = compressedData;
subblock.uncompressedSize = uncompressedSize;
return Uncompress( subblock_list() << subblock, perf );
}
private:
int m_compressionLevel = 0; // 0 = use codec's default
size_type m_subblockSize = 0; // 0 = use largest possible subblocks
uint8 m_itemSize = 1;
bool m_byteShuffle = true;
bool m_checksums = true;
protected:
/*!
* Returns the length in bytes of the smallest contiguous data block that
* can be compressed with this algorithm.
*/
virtual size_type MinBlockSize() const = 0;
/*!
* Returns the length in bytes of the largest contiguous data block that can
* be compressed with this algorithm.
*/
virtual size_type MaxBlockSize() const = 0;
/*!
* Returns the maximum length in bytes of the contiguous block necessary to
* compress a contiguous block of the specified \a size in bytes.
*/
virtual size_type MaxCompressedBlockSize( size_type size ) const = 0;
/*!
* Compression of a contiguous block starting at \a inputData with
* \a inputSize length in bytes, using the specified compression \a level.
* The compressed data will be written as a contiguous block starting at
* \a outputData, with length smaller than or equal to \a outputSize.
* Returns the number of bytes written to \a outputData, or zero if the data
* are not compressible.
*/
virtual size_type CompressBlock( void* outputData, size_type outputSize,
const void* inputData, size_type inputSize, int level ) const = 0;
/*!
* Decompression of a contiguous compressed block starting at \a inputData
* with \a inputSize length in bytes. The uncompressed data will be written
* as a contiguous block starting at \a outputData, with length equal to
* \a outputSize. Returns the number of bytes written to \a outputData,
* which should be equal to \a outputSize, or smaller in the event of error.
*/
virtual size_type UncompressBlock( void* outputData, size_type outputSize,
const void* inputData, size_type inputSize ) const = 0;
/*!
* Byte shuffling algorithm applied to \a size bytes starting at \a data,
* with element length \a itemSize in bytes. Returns the shuffled data as a
* ByteArray object.
*/
static ByteArray Shuffle( const uint8* data, size_type size, size_type itemSize )
{
ByteArray shuffled( size );
if ( size > 0 && data != nullptr )
{
size_type numberOfItems = size / itemSize;
ByteArray::iterator s = shuffled.Begin();
for ( size_type j = 0; j < itemSize; ++j )
{
ByteArray::const_iterator u = data + j;
for ( size_type i = 0; i < numberOfItems; ++i, ++s, u += itemSize )
*s = *u;
}
::memcpy( s, data + numberOfItems*itemSize, size % itemSize );
}
return shuffled;
}
/*!
* Reverse byte shuffling algorithm (or \e unshuffling) applied to \a size
* bytes starting at \a data, with element length \a itemSize in bytes.
* Returns the unshuffled data as a ByteArray object.
*/
static ByteArray Unshuffle( const uint8* data, size_type size, size_type itemSize )
{
ByteArray unshuffled( size );
if ( size > 0 && data != nullptr )
{
size_type numberOfItems = size / itemSize;
ByteArray::const_iterator s = data;
for ( size_type j = 0; j < itemSize; ++j )
{
ByteArray::iterator u = unshuffled.At( j );
for ( size_type i = 0; i < numberOfItems; ++i, ++s, u += itemSize )
*u = *s;
}
::memcpy( unshuffled.At( numberOfItems*itemSize ), s, size % itemSize );
}
return unshuffled;
}
/*!
* In-place reverse byte shuffling algorithm (or \e unshuffling) applied to
* \a size bytes starting at \a data, with element length \a itemSize in
* bytes.
*/
static void InPlaceUnshuffle( uint8* data, size_type size, size_type itemSize )
{
if ( size > 0 && data != nullptr )
{
const ByteArray shuffled( data, data+size );
size_type numberOfItems = size / itemSize;
ByteArray::const_iterator s = shuffled.Begin();
for ( size_type j = 0; j < itemSize; ++j )
{
ByteArray::iterator u = data + j;
for ( size_type i = 0; i < numberOfItems; ++i, ++s, u += itemSize )
*u = *s;
}
}
}
/*!
* Helper function to throw an error message with inclusion of the algorithm
* name.
*/
void Throw( const String& errorMessage ) const;
friend class PCL_CompressionEngine;
friend class PCL_DecompressionEngine;
};
// ----------------------------------------------------------------------------
/*!
* \class ZLibCompression
* \brief Implementation of the ZLib/Deflate compression algorithm.
*
* This class implements the deflate lossless compression algorithm in the
* standard zlib format. This is the default PixInsight/XISF compression codec.
*
* The underlying implementation in the PixInsight core application is the
* well-known zlib library written by Jean-Loup Gailly and Mark Adler.
*
* \b References
*
* \li Jean-Loup Gailly, L. Peter Deutsch (1996), RFC 1950: <em>ZLIB Compressed
* Data Format Specification version 3.3</em>
*
* \li Jean-Loup Gailly, L. Peter Deutsch (1996), RFC 1951: <em>DEFLATE
* Compressed Data Format Specification version 1.3</em>
*
* \li Greg Roelofs, Mark Adler, Zlib Home Site: http://www.zlib.net/
*
* \ingroup compression_classes
* \sa Compression, LZ4Compression, LZ4HCCompression, BloscLZCompression
*/
class PCL_CLASS ZLibCompression : public Compression
{
public:
/*!
* Returns the name of this data compression algorithm (ZLib).
*/
String AlgorithmName() const override
{
return "ZLib";
}
/*!
*/
int MaxCompressionLevel() const override;
/*!
*/
int DefaultCompressionLevel() const override;
private:
/*!
*/
size_type MinBlockSize() const override;
/*!
*/
size_type MaxBlockSize() const override;
/*!
*/
size_type MaxCompressedBlockSize( size_type size ) const override;
/*!
*/
size_type CompressBlock( void* outputData, size_type outputSize,
const void* inputData, size_type inputSize, int level ) const override;
/*!
*/
size_type UncompressBlock( void* outputData, size_type outputSize,
const void* inputData, size_type inputSize ) const override;
};
// ----------------------------------------------------------------------------
/*!
* \class LZ4Compression
* \brief Implementation of the LZ4 compression algorithm.
*
* This class implements the LZ4 compression algorithm by Yann Collet.
*
* LZ4 is a lossless data compression algorithm focused on compression and
* decompression speed.
*
* The underlying implementation in the PixInsight core application is the
* reference implementation by Yann Collet, which has been released under a New
* BSD license.
*
* \b References
*
* \li LZ4 source code repository: https://github.com/Cyan4973/lz4
*
* \li LZ4 website: http://cyan4973.github.io/lz4/
*
* \ingroup compression_classes
* \sa Compression, LZ4HCCompression, ZLibCompression, BloscLZCompression
*/
class PCL_CLASS LZ4Compression : public Compression
{
public:
/*!
* Returns the name of this data compression algorithm (LZ4-HC).
*/
String AlgorithmName() const override
{
return "LZ4";
}
/*!
*/
int MaxCompressionLevel() const override;
/*!
*/
int DefaultCompressionLevel() const override;
private:
/*!
*/
size_type MinBlockSize() const override;
/*!
*/
size_type MaxBlockSize() const override;
/*!
*/
size_type MaxCompressedBlockSize( size_type size ) const override;
/*!
*/
size_type CompressBlock( void* outputData, size_type outputSize,
const void* inputData, size_type inputSize, int level ) const override;
/*!
*/
size_type UncompressBlock( void* outputData, size_type outputSize,
const void* inputData, size_type inputSize ) const override;
};
// ----------------------------------------------------------------------------
/*!
* \class LZ4HCCompression
* \brief Implementation of the LZ4-HC compression algorithm.
*
* This class implements the LZ4 compression algorithm (high compression
* variant) by Yann Collet.
*
* LZ4 is a lossless data compression algorithm focused on compression and
* decompression speed.
*
* The underlying implementation in the PixInsight core application is the
* reference implementation by Yann Collet, which has been released under a New
* BSD license.
*
* \b References
*
* \li LZ4 source code repository: https://github.com/Cyan4973/lz4
*
* \li LZ4 website: http://cyan4973.github.io/lz4/
*
* \ingroup compression_classes
* \sa Compression, LZ4Compression, ZLibCompression, BloscLZCompression
*/
class PCL_CLASS LZ4HCCompression : public Compression
{
public:
/*!
* Returns the name of this data compression algorithm (LZ4-HC).
*/
String AlgorithmName() const override
{
return "LZ4-HC";
}
/*!
*/
int MaxCompressionLevel() const override;
/*!
*/
int DefaultCompressionLevel() const override;
private:
/*!
*/
size_type MinBlockSize() const override;
/*!
*/
size_type MaxBlockSize() const override;
/*!
*/
size_type MaxCompressedBlockSize( size_type size ) const override;
/*!
*/
size_type CompressBlock( void* outputData, size_type outputSize,
const void* inputData, size_type inputSize, int level ) const override;
/*!
*/
size_type UncompressBlock( void* outputData, size_type outputSize,
const void* inputData, size_type inputSize ) const override;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_Compression_h
// ----------------------------------------------------------------------------
// EOF pcl/Compression.h - Released 2022-03-12T18:59:29Z
-829
View File
@@ -1,829 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Console.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Console_h
#define __PCL_Console_h
/// \file pcl/Console.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/StringList.h>
namespace pcl
{
// ----------------------------------------------------------------------------
class PCL_CLASS View;
/*!
* \class Console
* \brief A high-level interface to a PixInsight processing console.
*
* The PixInsight platform provides three different user interfaces implemented
* in the PixInsight core application: a graphical user interface (GUI), a
* scripting interface (the PixInsight JavaScript runtime), and a command-line
* interface. The %Console class is a high-level abstraction that represents
* the %Process %Console window of the PixInsight core application, which
* implements the entire command-line and console text input/output
* functionality in PixInsight.
*
* A module can instantiate %Console to perform direct text input/output
* operations. %Console objects are often used to display information about
* ongoing processes, to let the user abort a process, or to put a process in a
* wait state to perform a modal user interface operation (e.g., showing a
* message box) in a thread-safe way.
*
* From the module developer perspective, each module has an associated
* console. Such associations between modules and consoles are managed
* automatically by internal core and PCL routines: module developers just need
* to instantiate the %Console class and use its member functions.
*
* For example, writing a message to the console can be as simple as:
*
* \code
* Console().WriteLn( "Hello, PixInsight" );
* \endcode
*
* Stream-style console insertion and extraction operators are also available.
* For example, this is equivalent to the above code:
*
* \code
* Console() << "Hello, PixInsight" << '\n';
* \endcode
*
* When you need to output formatted data, you can use the String::Format()
* family of functions. These functions are similar to the standard printf() C
* runtime function:
*
* \code
* Console console;
* console.WriteLn( String().Format( "Radius = %.6f, Angle = %+.2f&deg;", r, Deg( a ) ) );
* \endcode
*
* PixInsight consoles can understand and reproduce the full set of ISO-8859-1
* HTML entities. You see an example on the code fragment above: the \c "&deg;"
* entity prints a <em>degree symbol</em> on the console.
*
* PixInsight consoles can also interpret a number of \e tags, similar to HTML,
* to perform special actions and formatting operations. For example:
*
* \code
* Console() << "<end><cbr>This is <b>bold</b> and this is <i>italics</i><br>";
* \endcode
*
* In this example, the "<end>" tag moves the cursor after the last character
* in the console, then the "<cbr>" tag (<em>conditional break</em>) generates
* a new line only if the current line is not empty. This ensures that
* subsequent text output will start on an empty line at the end of the current
* console contents. The "<b>" and "</b>" tags write text in a bold type face,
* and the "<i>" and "</i>" pair write text in italics. This is just a minimal
* fraction of the rich set of tags understood by PixInsight consoles.
*
* As we describe in detail below, PixInsight consoles support standard ANSI
* escape codes, and can also be used to render inline HTML contents.
*
* It must be pointed out that the entire text output functionality of %Console
* is also available for TextBox controls. A module can instantiate a %TextBox
* control to provide rich text-based output as a process log, the output of an
* external process, or an information panel based on HTML tables, just to name
* a few possibilities implemented frequently.
*
* <h2>%Console Tags</h2>
*
* Here is a comprehensive list of supported console tags at the time of
* publishing this documentation. New functionality implemented through console
* tags will be documented here as new versions are released.
*
* <table border="1" cellpadding="4" cellspacing="0">
*
* <tr><td>\<b\>\</b\></td> <td>Enables/disables bold text.</td></tr>
* <tr><td>\<i\>\</i\></td> <td>Enables/disables italics text.</td></tr>
* <tr><td>\<u\>\</u\></td> <td>Enables/disables underlined text.</td></tr>
* <tr><td>\<o\>\</o\></td> <td>Enables/disables overlined text.</td></tr>
* <tr><td>\<sub\>\</sub\></td> <td>Enables/disables subscript text.</td></tr>
* <tr><td>\<sup\>\</sup\></td> <td>Enables/disables superscript text.</td></tr>
*
* <tr><td>\<br\></td> <td>Line break.</td></tr>
* <tr><td>\<br/\></td> <td>Line break, XML compliant (same as \<br\>).</td></tr>
* <tr><td>\<cbr\></td> <td>Conditional line break: sends a line break if the cursor is not at the beginning of an empty line.</td></tr>
* <tr><td>\<cbr/\></td> <td>Conditional line break, XML compliant (same as \<cbr\>).</td></tr>
*
* <tr><td>\<bsp\></td> <td>Backspace: deletes the previous character and moves the cursor one step left, only if it is not at the beginning of a line.</td></tr>
* <tr><td>\<end\></td> <td>Moves the cursor to the end of the console.</td></tr>
* <tr><td>\<beg\></td> <td>Moves the cursor to the beginning of the console.</td></tr>
* <tr><td>\<bwd\></td> <td>Moves the cursor to the previous character, only if it is not at the beginning of a line.</td></tr>
* <tr><td>\<fwd\></td> <td>Moves the cursor to the next character, only if it is not at the end of a line.</td></tr>
* <tr><td>\<eol\></td> <td>Moves the cursor to the end of the current line.</td></tr>
* <tr><td>\<bol\></td> <td>Moves the cursor to the beginning of the current line.</td></tr>
* <tr><td>\<up\></td> <td>Moves the cursor to the previous line, if it is not already at the first line.</td></tr>
* <tr><td>\<down\></td> <td>Moves the cursor to the next line, if it is not already at the last line.</td></tr>
*
* <tr><td>\<clr\></td> <td>Clears the console. Avoid issuing this tag arbitrarily - please see the documentation for Console::Clear() for more information.</td></tr>
* <tr><td>\<clreol\></td> <td>Deletes the text from the current cursor position (included) to the end of the current line.</td></tr>
* <tr><td>\<clrbol\></td> <td>Deletes the text from the current cursor position (included) to the beginning of the current line.</td></tr>
* <tr><td>\<clrend\></td> <td>Deletes the text from the current cursor position (included) to the end of the console.</td></tr>
* <tr><td>\<clrbeg\></td> <td>Deletes the text from the current cursor position (included) to the beginning of the console. Avoid issuing this tag arbitrarily - please see the documentation for Console::Clear() for more information.</td></tr>
*
* <tr><td>\<nowrap\>\</nowrap\></td> <td>Disables/enables word wrapping of text lines.</td></tr>
* <tr><td>\<notags\>\</notags\></td> <td>Disables/enables tag interpretation, except the \</notags\> tag, which is always interpreted.</td></tr>
* <tr><td>\<noentities\>\</noentities\></td> <td>Disables/enables interpretation of ISO-8859-1 entities.</td></tr>
* <tr><td>\<raw\>\</raw\></td> <td>Disables/enables interpretation of tags, except the \</raw\> tag, and ISO-8859-1 entities. \<raw\> is equivalent to (but faster than) \<noentities\>\<notags\>.</td></tr>
* <tr><td>\<code\>\</code\></td> <td>Equivalent to \<monospace\>\<raw\>. Useful to show source code fragments.</td></tr>
*
* <tr><td>\<monospace\></td> <td>Selects a platform-dependent, monospaced font.</td></tr>
* <tr><td>\<sans\></td> <td>Selects a platform-dependent, sans-serif font.</td></tr>
* <tr><td>\<serif\></td> <td>Selects a platform-dependent, serif font.</td></tr>
* <tr><td>\<courier\></td> <td>Selects the Courier font, or the nearest available monspaced font, depending on the platform.</td></tr>
* <tr><td>\<helvetica\></td> <td>Selects the Helvetica font, or the nearest available sans-serif font, depending on the platform.</td></tr>
* <tr><td>\<times\></td> <td>Selects the Times font, or the nearest available serif font, depending on the platform.</td></tr>
* <tr><td>\<default-font\></td> <td>Selects the default console font (usually a monospaced font; but user-selectable through preferences).</td></tr>
* <tr><td>\<reset-font\></td> <td>Resets all text settings and styles to default values.</td></tr>
*
* <tr><td>\<show\></td> <td>If this console corresponds to the processing console window, shows it if it's currently hidden and docked in the PixInsight core application window; otherwise this tag is ignored. Equivalent to calling the Console::Show() member function.</td></tr>
* <tr><td>\<hide\></td> <td>If this console corresponds to the processing console window, hides it if it's currently visible and docked in the PixInsight core application window; otherwise this tag is ignored. Equivalent to calling the Console::Hide() member function.</td></tr>
* <tr><td>\<flush\></td> <td>Causes any pending data to be written immediately to the console. If there is no unwritten data for this console, this tag has no effect. Equivalent to calling the Console::Flush() member function.</td></tr>
*
* <tr><td>\<html\>\</html\></td> <td>Enables/disables HTML mode. In HTML mode, the console interprets and renders a comprehensive set of HTML 4 tags, including full support of tables, as well as a significant part of Level 2 CSS (Cascading Style Sheets) directives. In HTML mode, PixInsight console tags are either ignored or interpreted with their corresponding meaning in HTML 4.</td></tr>
*
* </table>
*
* In addition, the \\n, \\r and \\b escape characters can be used in place of
* the \<br\>, \<bol\> and \<bsp\> tags, respectively.
*
* <h2>Character Entities</h2>
*
* PixInsight consoles fully recognize and interpret the whole set of
* HTML 4 character entities, including all ISO 8859-1 characters and all
* character entities for symbols, mathematical symbols, Greek letters,
* markup-significant and internationalization characters.
*
* Character entities are of the form:
*
* <tt>\<entity-name\>;</tt>
*
* where \<entity-name\> is one of the references included in the
* following W3C Recommendation document:
*
* http://www.w3.org/TR/REC-html40/sgml/entities.html
*
* <h2>HTML Mode</h2>
*
* The \<html\> tag allows you to put a PixInsight console in <em>HTML
* mode</em>. In this mode you can embed HTML 4 contents directly. For example,
* this code:
*
* \code
* Console console;
* console.Write( "<html>"
* "<table border="1" cellpadding="4" cellspacing="0">"
* "<tr><td>If this is foo</td> <td>and this is bar,</td></tr>"
* "<tr><td>then</td> <td>this can only be foo bar.</td></tr>"
* "</table>"
* "</html>" ); \endcode
*
* generates an HTML table with two rows and two columns. PixInsight consoles
* support most of the HTML 4 specification, including a subset of CSS2. For
* detaled information, this document describes HTML support in Qt, which is
* the underlying implementation in current versions of PixInsight:
*
* http://qt-project.org/doc/qt-4.8/richtext-html-subset.html
*
* In HTML mode, that is, within a pair of \<html\>\</html\> tags, no
* PixInsight console tags or ANSI escape codes are recognized or interpreted.
*
* <h2>ANSI Escape Codes</h2>
*
* Since version 1.8.1 of the PixInsight core application, PixInsight consoles
* support a large set of ANSI CSI (Control Sequence Introducer) codes. For a
* detailed description of ANSI escape codes, refer to the following documents:
*
* http://en.wikipedia.org/wiki/ANSI_escape_code
* http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
*
* The following table describes the supported CSI codes in the current version
* of PixInsight. ESC represents the escape control character, whose ASCII code
* is 27<sub>10</sub> = 1B<sub>16</sub>. The CSI sequence is ESC followed by
* the left square bracket character, represented as the ESC[ sequence. See the
* examples given at the end of the table.
*
* <table border="1" cellpadding="4" cellspacing="0">
*
* <tr><td><tt>ESC[ n A</tt></td> <td>%Cursor up n Times (default n=1) (CUU)</td></tr>
* <tr><td><tt>ESC[ n B</tt></td> <td>%Cursor down n Times (default n=1) (CUD)</td></tr>
* <tr><td><tt>ESC[ n C</tt></td> <td>%Cursor forward n Times (default n=1) (CUF)</td></tr>
* <tr><td><tt>ESC[ n D</tt></td> <td>%Cursor backward n Times (default n=1) (CUB)</td></tr>
* <tr><td><tt>ESC[ n E</tt></td> <td>%Cursor to next line n Times (default n=1) (CNL)</td></tr>
* <tr><td><tt>ESC[ n F</tt></td> <td>%Cursor to preceding line n Times (default n=1) (CPL)</td></tr>
* <tr><td><tt>ESC[ n G</tt></td> <td>%Cursor to character absolute column n (default n=1) (CHA)</td></tr>
* <tr><td><tt>ESC[ n;m H</tt></td> <td>%Cursor position to row n and column m (default n=m=1) (CUP)</td></tr>
* <tr><td><tt>ESC[ n;m f</tt></td> <td>Horizontal & Vertical Position (HVP). Same as H.</td></tr>
*
* <tr><td><tt>ESC[ n J</tt></td> <td>Erase in Display (ED)<br>
* <table border="1" cellpadding="4" cellspacing="0" width="100%">
* <tr><td><tt>n = 0</tt></td> <td>Erase below up to the end of text. This is the default if no n is specified.</td></tr>
* <tr><td><tt>n = 1</tt></td> <td>Erase above up to the start of text.</td></tr>
* <tr><td><tt>n = 2</tt></td> <td>Erase all (entire console).</td></tr>
* </table></td></tr>
*
* <tr><td><tt>ESC[ n K</tt></td> <td>Erase in Line (EL)<br>
* <table border="1" cellpadding="4" cellspacing="0" width="100%">
* <tr><td><tt>n = 0</tt></td> <td>Erase to right up to the end of line. This is the default if no n is specified.</td></tr>
* <tr><td><tt>n = 1</tt></td> <td>Erase to left up to the start of line.</td></tr>
* <tr><td><tt>n = 2</tt></td> <td>Erase the whole line.</td></tr>
* </table></td></tr>
*
* <tr><td><tt>ESC[ n L</tt></td> <td>Insert n line(s) (default n=1) (IL)</td></tr>
* <tr><td><tt>ESC[ n M</tt></td> <td>Delete n line(s) (default n=1) (DL)</td></tr>
* <tr><td><tt>ESC[ n P</tt></td> <td>Delete n character(s) (default n=1) (DCH)</td></tr>
*
* <tr><td><tt>ESC[ ... m</tt></td> <td>Set graphics rendition (SGR)<br>
* The ellipsis represents a list of one or more integer arguments separated by semi-colons. The following arguments are recognized:<br>
* <table border="1" cellpadding="4" cellspacing="0" width="100%">
* <tr><td><tt>0</tt></td> <td>Reset all font and color properties to default values.</td></tr>
* <tr><td><tt>1</tt></td> <td>Bold font</td></tr>
* <tr><td><tt>2</tt></td> <td>Faint (decreased intensity) - ignored (not implemented)</td></tr>
* <tr><td><tt>3</tt></td> <td>Italic font</td></tr>
* <tr><td><tt>4</tt></td> <td>Underline font</td></tr>
* <tr><td><tt>5</tt></td> <td>Blink (slow) - reinterpreted - selects a bold font.</td></tr>
* <tr><td><tt>6</tt></td> <td>Blink (fast) - reinterpreted - selects a bold font.</td></tr>
* <tr><td><tt>7</tt></td> <td>Inverse colors (swap default foreground and background)</td></tr>
* <tr><td><tt>8</tt></td> <td>Invisible - ignored (not implemented)</td></tr>
* <tr><td><tt>9</tt></td> <td>Strike out font</td></tr>
* <tr><td><tt>21</tt></td> <td>Bold font: disable</td></tr>
* <tr><td><tt>22</tt></td> <td>Normal color - ignored (not implemented)</td></tr>
* <tr><td><tt>23</tt></td> <td>Italic font: disable</td></tr>
* <tr><td><tt>24</tt></td> <td>Underline font: disable</td></tr>
* <tr><td><tt>25</tt></td> <td>Blink: disable - reinterpreted - disables bold font (same as 21).</td></tr>
* <tr><td><tt>27</tt></td> <td>Inverse colors: disable</td></tr>
* <tr><td><tt>28</tt></td> <td>Visible - ignored (not implemented)</td></tr>
* <tr><td><tt>29</tt></td> <td>Strike out font: disable</td></tr>
* <tr><td><tt>30 ... 37</tt></td> <td>Set foreground color to n-30: 0=black, 1=red, 2=green, 3=yellow, 4=blue, 5=magenta, 6=cyan, 7=white.</td></tr>
* <tr><td><tt>38</tt></td> <td>KDE's Konsole extended 24-bit color space: Set foreground color (see note below).</td></tr>
* <tr><td><tt>39</tt></td> <td>Default foreground color.</td></tr>
* <tr><td><tt>40 ... 47</tt></td> <td>Set background color to n-40. Colors are the same as for 30 ... 37.</td></tr>
* <tr><td><tt>48</tt></td> <td>KDE's Konsole extended 24-bit color space: Set background color (see note below).</td></tr>
* <tr><td><tt>49</tt></td> <td>Default background color.</td></tr>
* <tr><td><tt>53</tt></td> <td>Overline font</td></tr>
* <tr><td><tt>55</tt></td> <td>Overline font: disable</td></tr>
* </table></td></tr>
*
* <tr><td><tt>ESC[s</tt></td> <td>Save %Cursor Position (SCP)</td></tr>
* <tr><td><tt>ESC[u</tt></td> <td>Restore %Cursor Position (RCP)</td></tr>
*
* </table>
*
* KDE Konsole 24-bit colors use the following format:
*
* <tt>Select RGB foreground color: ESC[ ... 38;2;r;g;b ... m</tt><br>
* <tt>Select RGB background color: ESC[ ... 48;2;r;g;b ... m</tt>
*
* where r, g and b are the red, green and blue components in the [0,255]
* range. For detailed information on these codes, see the following document:
*
* https://projects.kde.org/projects/kde/applications/konsole/repository/revisions/master/entry/doc/user/README.moreColors
*
* <b>Examples</b>
*
* Write a text line using a bold font:
*
* \code
* Console().WriteLn( "\x1b[1mThis is bold text\x1b[21m" ); \endcode
*
* Write a text line in orange color using an italic font:
*
* \code
* String programName;
* Console().WriteLn( "<end><cbr><br>\x1b[3;38;2;255;128;0m" + programName + "\x1b[39;23m" ); \endcode
*
* Write some text at the beginning of the current line, removing any previous
* contents:
*
* \code
* Console().Write( "\x1b[2KThis text replaces the whole line" ); \endcode
*
* \sa StatusMonitor, StandardStatus, SpinStatus, MuteStatus, Thread
*/
class PCL_CLASS Console
{
public:
/*!
* Constructs a %Console object.
*/
Console();
/*!
* Copy constructor, disabled because %Console instances represent unique
* objects that cannot be copied.
*/
Console( const Console& ) = delete;
/*!
* Move constructor.
*/
Console( Console&& x )
: m_handle( x.m_handle )
, m_thread( x.m_thread )
{
x.m_handle = x.m_thread = nullptr;
}
/*!
* Copy assignment operator, disabled because %Console instances represent
* unique objects that cannot be copied.
*/
Console& operator =( const Console& ) = delete;
/*!
* Move assignment operator. Returns a reference to this object.
*/
Console& operator =( Console&& x )
{
if ( &x != this )
{
m_handle = x.m_handle;
m_thread = x.m_thread;
x.m_handle = x.m_thread = nullptr;
}
return *this;
}
/*!
* Destroys a %Console object.
*/
virtual ~Console();
/*!
* Writes an Unicode string \a s to this console.
*/
void Write( const String& s );
/*!
* Writes an Unicode string \a s to this console and appends a newline
* escape character ('\\n').
*
* Note that this function is faster than appending a newline character to
* the string, such as a call to Write( s + '\\n' ).
*/
void WriteLn( const String& s );
/*!
* Sends a single newline escape character ('\\n') to the console.
*
* Note that this function is faster than writing a newline directly with a
* call to Write( '\\n' ).
*/
void WriteLn();
/*!
* Writes an informative note message to this console.
*
* This function writes the specified Unicode string \a s using standard
* ANSI terminal color number 2 (green in the default palette). The
* implementation of this member function uses ANSI escape codes.
*/
void Note( const String& s )
{
Write( "\x1b[32m" + s + "\x1b[39m" );
}
/*!
* Writes an informative note message to this console and appends a newline
* escape character ('\\n').
*
* See the description of Note( const String& ).
*/
void NoteLn( const String& s )
{
WriteLn( "\x1b[32m" + s + "\x1b[39m" );
}
/*!
* Writes a warning message to this console.
*
* This function writes the specified Unicode string \a s using standard
* ANSI terminal color number 5 (magenta in the default palette). The
* implementation of this member function uses ANSI escape codes.
*/
void Warning( const String& s )
{
Write( "\x1b[35m" + s + "\x1b[39m" );
}
/*!
* Writes a warning message to this console and appends a newline escape
* character ('\\n').
*
* See the description of Warning( const String& ).
*/
void WarningLn( const String& s )
{
WriteLn( "\x1b[35m" + s + "\x1b[39m" );
}
/*!
* Writes a critical error message to this console.
*
* This function writes the specified Unicode string \a s using standard
* ANSI terminal color number 1 (red in the default palette). The
* implementation of this member function uses ANSI escape codes.
*/
void Critical( const String& s )
{
Write( "\x1b[31m" + s + "\x1b[39m" );
}
/*!
* Writes a critical error message to this console and appends a newline
* escape character ('\\n').
*
* See the description of Critical( const String& ).
*/
void CriticalLn( const String& s )
{
WriteLn( "\x1b[31m" + s + "\x1b[39m" );
}
/*!
* Reads a single character from this console and returns it.
*
* This function puts the current thread in wait state, then waits until a
* character can be obtained in the core application's GUI thread. This
* usually involves waiting for a keyboard event.
*
* \note This member function has not been implemented in the current PCL
* version. Calling it has not effect, and zero is always returned.
*/
int ReadChar();
/*!
* Reads a string from this console and returns it.
*
* This function puts the current thread in wait state, then opens a simple
* modal dialog box with a single-line edit control, where the user may
* enter a string. If the user cancels the input dialog, an empty string is
* returned.
*
* \note This member function has not been implemented in the current PCL
* version. Calling it has not effect, and an empty string is always
* returned.
*/
String ReadString();
/*!
* Returns true iff the current processing thread has been suspended by the
* PixInsight core application.
*/
bool Suspended() const;
/*!
* Returns true iff the current processing thread is in wait state.
*/
bool Waiting() const;
/*!
* Returns true iff the current processing thread can be aborted by the user.
*/
bool AbortEnabled() const;
/*!
* Returns true iff the user has requested to abort execution of the current
* processing thread.
*/
bool AbortRequested() const;
/*!
* Resets the current processing thread status.
*
* This function is useful to ignore an abort request for the current
* processing thread. For example, if the user requests to abort execution,
* a module may ask if she or he really wants to cancel, and if the user
* answers 'No', then this member function can be called to clear the
* existing abort request condition.
*
* \note This function must only be called when there is an active process
* running in the current module. It can only be called from the thread
* where either a reimplemented ProcessImplementation::ExecuteOn() or
* ProcessImplementation::ExecuteGlobal() member function has been invoked.
* An Error exception will be thrown otherwise.
*/
void ResetStatus();
/*!
* Enables abort requests for the current processing thread.
*
* \note This function must only be called when there is an active process
* running in the current module. It can only be called from the thread
* where either a reimplemented ProcessImplementation::ExecuteOn() or
* ProcessImplementation::ExecuteGlobal() member function has been invoked.
* An Error exception will be thrown otherwise.
*/
void EnableAbort();
/*!
* Disables abort requests for the current processing thread.
*
* \note This function must only be called when there is an active process
* running in the current module. It can only be called from the thread
* where either a reimplemented ProcessImplementation::ExecuteOn() or
* ProcessImplementation::ExecuteGlobal() member function has been invoked.
* An Error exception will be thrown otherwise.
*/
void DisableAbort();
/*!
* Accepts a pending abort request.
*
* \note This function must only be called when there is an active process
* running in the current module. It can only be called from the thread
* where either a reimplemented ProcessImplementation::ExecuteOn() or
* ProcessImplementation::ExecuteGlobal() member function has been invoked.
* An Error exception will be thrown otherwise.
*/
void Abort();
/*!
* Returns true iff this is a valid console object associated to an active
* processing thread.
*/
bool IsValid() const;
/*!
* Returns true iff this console is valid and has been created by the
* calling thread; either by the root thread or by a running Thread object.
*/
bool IsCurrentThreadConsole() const;
/*!
* Causes any pending data to be written immediately to this console. If
* there is no unwritten data for this console, this function has no effect.
*/
void Flush();
/*!
* Shows the %Process %Console window in the PixInsight core application.
*
* The visibility of a console can only be controlled if it is the process
* console window. Furthermore, a module cannot show or hide the console if
* it is not owned by a docked window; the visibility of a floating window
* cannot be changed programmatically from a module.
*
* This function returns true if the console could be shown (or hidden)
* successfully. Unlike most interface operations, console hide/show
* operations are not cached, so if this function returns true then you know
* that the %Process %Console window is currently visible.
*
* \note Calling this function from a running thread has no effect. Console
* visibility can only be changed from the root thread.
*/
bool Show( bool show = true );
/*!
* Hides the %Process %Console window in the PixInsight core application.
*
* This is a convenience function, equivalent to: Show( !hide )
*
* Returns true iff the console could be hidden (or shown) successfully.
* Refer to the Show() member function for more information.
*
* \note Calling this function from a running thread has no effect. Console
* visibility can only be changed from the root thread.
*/
bool Hide( bool hide = true )
{
return Show( !hide );
}
/*!
* Clears the console. This is a convenience function that simply writes the
* \<clr\> tag to the console.
*
* \note Calling this function from a running thread has no effect. The
* console output text of a Thread object cannot be erased by this function.
*
* \note In general, call this function only as a result of an explicit user
* request to clear the console. Clearing the console arbitrarily, without
* having an extremely good reason, is considered bad practice and can be
* a good argument to deny certification of a module.
*/
void Clear();
/*!
*
*/
void ExecuteCommand( const String& command );
/*!
* Executes a script file.
*
* \param filePath Path to the script file that will be executed. Must be
* a path to an existing script on the local filesystem.
*
* \param arguments A dynamic array, possibly empty, of StringKeyValue
* objects. Each object in this array represents a script
* argument. The key member is the parameter name, and the
* value member is the corresponding parameter value.
*
* The core application will load, parse, authorize and execute the
* specified script file. The scripting language will be detected
* automatically from the file name suffix in \a filePath. Currently the
* .scp and .js suffixes are interpreted for command-line shell scripts and
* JavaScript scripts, respectively. Future versions may accept more
* languages and apply language detection heuristics besides file suffixes.
*
* This member function returns normally if the script was loaded and
* executed. In the event of error, for example if the specified file does
* not exist or can't be accessed, or in the event of security errors or
* failure to authorize script execution from the calling module, this
* member function throws an Error exception.
*
* Note that command-line or JavaScript runtime execution errors cannot be
* reported by this function. That means that this function knows nothing
* about whether the script worked or not correctly, or if it did what was
* expected.
*
* For execution of JavaScript scripts, this function is equivalent to
* ExecuteScriptGlobal(), that is, JavaScript scripts are always executed in
* the global context by default. When executed, the JavaScript script will
* see the following static properties of the %Parameters JS runtime object:
*
* \c Parameters.isGlobalTarget will be set to true. \n
* \c Parameters.isViewTarget will be set to false. \n
* \c Parameters.targetView will be set to \c undefined.
*
* See ExecuteScriptOn() for execution of scripts in view contexts.
*
* \note If this function is called from a running thread, an Error
* exception will be thrown and nothing will be executed. In current
* versions of the PixInsight platform, scripts can only be executed from
* the root thread. The main reason for this limitation is that the
* JavaScript and command-line execution engines are not reentrant.
*/
void ExecuteScript( const String& filePath, const StringKeyValueList& arguments = StringKeyValueList() );
/*!
* Executes a script file in the global context. This is the default
* execution execution mode for all scripts.
*
* When a JavaScript script is executed through this member function, the
* following static properties of the %Parameters runtime object will be
* defined as described below:
*
* \c Parameters.isGlobalTarget will be set to true. \n
* \c Parameters.isViewTarget will be set to false. \n
* \c Parameters.targetView will be set to \c undefined.
*
* See ExecuteScript() for a detailed description of script execution from
* PCL/C++ code.
*/
void ExecuteScriptGlobal( const String& filePath, const StringKeyValueList& arguments = StringKeyValueList() );
/*!
* Executes a script file in the context of the specified \a view.
*
* When a JavaScript script is executed through this member function, the
* following static properties of the %Parameters runtime object will be
* defined as described below:
*
* \c Parameters.isGlobalTarget will be set to false. \n
* \c Parameters.isViewTarget will be set to true. \n
* \c Parameters.targetView will reference the specified \a view.
*
* See ExecuteScript() for a detailed description of script execution from
* PCL/C++ code.
*/
void ExecuteScriptOn( const View& view, const String& filePath, const StringKeyValueList& arguments = StringKeyValueList() );
protected:
void* m_handle = nullptr;
private:
void* m_thread = nullptr;
};
// ----------------------------------------------------------------------------
/*!
* \defgroup console_operators Console Insertion and Extraction Operators
*/
/*!
* Writes an object \a t to the console \a o. The type T must have
* convert-to-string semantics. Returns a reference to the console \a o.
* \ingroup console_operators
*/
template <typename T>
inline Console& operator <<( Console& o, T t )
{
o.Write( String( t ) );
return o;
}
/*!
* Writes a null-terminated string \a s to the console \a o.
* Returns a reference to the console \a o.
* \ingroup console_operators
*/
inline Console& operator <<( Console& o, const char* s )
{
o.Write( s );
return o;
}
/*!
* Writes a string \a s to the console \a o.
* Returns a reference to the console \a o.
* \ingroup console_operators
*/
inline Console& operator <<( Console& o, const String& s )
{
o.Write( s );
return o;
}
/*!
* Reads a character \a c from the console \a o.
* Returns a reference to the console \a o.
* \ingroup console_operators
*/
inline Console& operator >>( Console& o, char& c )
{
c = o.ReadChar();
return o;
}
/*!
* Reads a string \a s from the console \a o.
* Returns a reference to the console \a o.
* \ingroup console_operators
*/
inline Console& operator >>( Console& o, String& s )
{
s = o.ReadString();
return o;
}
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
#endif // __PCL_Console_h
// ----------------------------------------------------------------------------
// EOF pcl/Console.h - Released 2022-03-12T18:59:29Z
-199
View File
@@ -1,199 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Constants.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Constants_h
#define __PCL_Constants_h
/// \file pcl/Constants.h
#include <pcl/Defs.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class Const
* \brief Fundamental numeric constants
*
* Specialize this class to obtain constants of the appropriate floating-point
* types. For example: Const<double>::pi()
*/
template <typename T>
class PCL_CLASS Const
{
public:
/*!
* pi/4 (45 degrees)
*/
static constexpr T pi4 () { return T( 0.785398163397448309615660845819875725e+00L ); }
/*!
* pi/2 (90 degrees)
*/
static constexpr T pi2 () { return T( 0.157079632679489661923132169163975145e+01L ); }
/*!
* 3*pi/4 (135 degrees)
*/
static constexpr T _3pi4 () { return T( 0.2356194490192344928846982537459627175e+01L ); }
/*!
* The pi constant (180 degrees)
*/
static constexpr T pi () { return T( 0.31415926535897932384626433832795029e+01L ); }
/*!
* 5*pi/4 (225 degrees)
*/
static constexpr T _5pi4 () { return T( 0.3926990816987241548078304229099378625e+01L ); }
/*!
* 3*pi/2 (270 degrees)
*/
static constexpr T _3pi2 () { return T( 0.471238898038468985769396507491925435e+01L ); }
/*!
* 7*pi/4 (315 degrees)
*/
static constexpr T _7pi4 () { return T( 0.5497787143782138167309625920739130075e+01L ); }
/*!
* 2*pi (360 degrees)
*/
static constexpr T _2pi () { return T( 0.62831853071795864769252867665590058e+01L ); }
/*!
* 1/pi
*/
static constexpr T _1_pi () { return T( 0.3183098861837906715377675267450287224677e+00L ); }
/*!
* 2/pi
*/
static constexpr T _2_pi () { return T( 0.6366197723675813430755350534900574449355e+00L ); }
/*!
* 2/sqrt( pi )
*/
static constexpr T _2_sqrtpi () { return T( 0.11283791670955125738961589031215451688501e+01L ); }
/*!
* 180/pi - the radians-to-degrees conversion factor.
*/
static constexpr T deg () { return T( 0.572957795130823208767981548141051700441964e+02L ); }
/*!
* Pi/180 - the degrees-to-radians conversion factor.
*/
static constexpr T rad () { return T( 0.174532925199432957692369076848861272222e-01L ); }
/*!
* The Euler constant e.
*/
static constexpr T e () { return T( 0.27182818284590452353602874713526625e+01L ); }
/*!
* log2( e )
*/
static constexpr T log2e () { return T( 0.14426950408889634073599246810018920709799e+01L ); }
/*!
* log2( 10 )
*/
static constexpr T log210 () { return T( 0.33219280948873623478703194294893900118996e+01L ); }
/*!
* log10( e )
*/
static constexpr T log10e () { return T( 0.4342944819032518276511289189166050837280e+00L ); }
/*!
* log10( 2 )
*/
static constexpr T log102 () { return T( 0.3010299956639811952137388947244930416265e+00L ); }
/*!
* ln( 2 )
*/
static constexpr T ln2 () { return T( 0.6931471805599453094172321214581766e+00L ); }
/*!
* ln( 10 )
*/
static constexpr T ln10 () { return T( 0.23025850929940456840179914546843642e+01L ); }
/*!
* sqrt( 2 )
*/
static constexpr T sqrt2 () { return T( 0.14142135623730950488016887242096980785696e+01L ); }
/*!
* 1/sqrt( 2 ) = sqrt( 2 )/2
*/
static constexpr T _1_sqrt2 () { return T( 0.7071067811865475244008443621048490392848e+00L ); }
/*!
* sqrt( 2 )/2 = 1/sqrt( 2 )
*/
static constexpr T sqrt2_2 () { return T( 0.7071067811865475244008443621048490392848e+00L ); }
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_Constants_h
// ----------------------------------------------------------------------------
// EOF pcl/Constants.h - Released 2022-03-12T18:59:29Z
-134
View File
@@ -1,134 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Container.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Container_h
#define __PCL_Container_h
/// \file pcl/Container.h
#include <pcl/Defs.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class Container
* \brief Root base class of all PCL containers.
*/
class PCL_CLASS Container
{
};
/*!
* \class DirectContainer
* \brief Root base class of all PCL containers of objects.
*/
template <typename T>
class PCL_CLASS DirectContainer : public Container
{
public:
typedef T item_type;
};
/*!
* \class IndirectContainer
* \brief Root base class of all PCL containers of pointers to objects.
*/
template <typename T>
class PCL_CLASS IndirectContainer : public Container
{
public:
typedef T* item_type;
};
/*!
* \class DirectSortedContainer
* \brief Root base class of all PCL sorted containers of objects.
*/
template <typename T>
class PCL_CLASS DirectSortedContainer: public DirectContainer<T>
{
};
/*!
* \class IndirectSortedContainer
* \brief Root base class of all PCL sorted containers of pointers to objects.
*/
template <typename T>
class PCL_CLASS IndirectSortedContainer : public IndirectContainer<T>
{
};
#define PCL_ASSERT_DIRECT_CONTAINER( C, T ) \
static_assert( std::is_base_of<DirectContainer<T>, C>::value, \
"Argument type must derive from DirectContainer<T>." )
#define PCL_ASSERT_INDIRECT_CONTAINER( C, T ) \
static_assert( std::is_base_of<IndirectContainer<T>, C>::value, \
"Argument type must derive from IndirectContainer<T>." )
#define PCL_ASSERT_CONTAINER( C, T ) \
static_assert( std::is_base_of<DirectContainer<T>, C>::value \
|| std::is_base_of<IndirectContainer<T>, C>::value, \
"Argument type must derive from DirectContainer<T> or IndirectContainer<T>." )
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_Container_h
// ----------------------------------------------------------------------------
// EOF pcl/Container.h - Released 2022-03-12T18:59:29Z
-1869
View File
File diff suppressed because it is too large Load Diff
-359
View File
@@ -1,359 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Convolution.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Convolution_h
#define __PCL_Convolution_h
/// \file pcl/Convolution.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/AutoPointer.h>
#include <pcl/InterlacedTransformation.h>
#include <pcl/KernelFilter.h>
#include <pcl/ParallelProcess.h>
#include <pcl/ThresholdedTransformation.h>
#define __PCL_CONVOLUTION_TINY_WEIGHT 1.0e-20
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class Convolution
* \brief Discrete two-dimensional nonseparable convolution in the spatial
* domain
*
* %Convolution implements a fully multithreaded, two-dimensional discrete
* nonseparable convolution algorithm. It performs automatic fixing of
* border artifacts by applying Neumann boundary conditions (mirroring).
*
* \note ImageTransformation is a virtual base class of %Convolution.
*
* \sa SeparableConvolution, FFTConvolution, KernelFilter
*/
class PCL_CLASS Convolution : public InterlacedTransformation,
public ThresholdedTransformation,
public ParallelProcess
{ // NB: ImageTransformation is a virtual base class
public:
/*!
* Default constructor.
*
* \note This constructor yields an uninitialized instance that cannot be
* used before explicit association with a KernelFilter instance.
*/
Convolution() = default;
/*!
* Constructs a %Convolution instance with the specified filter.
*
* \param filter Response function, or <em>convolution filter</em>. The
* specified object does not have to remain valid while this
* instance is actively used, since %Convolution owns a
* private copy of the filter (note that KernelFilter is a
* reference-counted class).
*/
Convolution( const KernelFilter& filter )
{
SetFilter( filter );
}
/*!
* Copy constructor.
*/
Convolution( const Convolution& x )
: InterlacedTransformation( x )
, ThresholdedTransformation( x )
, ParallelProcess( x )
, m_weight( x.m_weight )
, m_highPass( x.m_highPass )
, m_rawHighPass( x.m_rawHighPass )
, m_rescaleHighPass( x.m_rescaleHighPass )
{
if ( !x.m_filter.IsNull() )
m_filter = x.m_filter->Clone();
}
/*!
* Move constructor.
*/
Convolution( Convolution&& ) = default;
/*!
* Destroys this %Convolution object.
*/
virtual ~Convolution()
{
}
/*!
* Copy assignment operator. Returns a reference to this object.
*/
Convolution& operator =( const Convolution& x )
{
if ( &x != this )
{
(void)InterlacedTransformation::operator =( x );
(void)ThresholdedTransformation::operator =( x );
(void)ParallelProcess::operator =( x );
if ( x.m_filter.IsNull() )
m_filter.Destroy();
else
m_filter = x.m_filter->Clone();
m_weight = x.m_weight;
m_highPass = x.m_highPass;
m_rawHighPass = x.m_rawHighPass;
m_rescaleHighPass = x.m_rescaleHighPass;
}
return *this;
}
/*!
* Move assignment operator. Returns a reference to this object.
*/
Convolution& operator =( Convolution&& ) = default;
/*!
* Returns a reference to the kernel filter currently associated with this
* %Convolution object.
*
* If this object has not been initialized, this member function returns an
* empty kernel filter.
*/
const KernelFilter& Filter() const
{
PCL_PRECONDITION( !m_filter.IsNull() )
return *m_filter;
}
/*!
* Sets a new kernel \a filter to be applied by this %Convolution object.
*/
void SetFilter( const KernelFilter& filter )
{
m_filter = filter.Clone();
CacheFilterProperties();
}
/*!
* Returns the current filter weight. The filter weight is computed each
* time a kernel filter is associated with this object. It is only
* applied for low-pass filters as a normalization factor. For more
* information, see the documentation for KernelFilter::Weight().
*
* The filter weight and other filter properties are cached in private data
* members for quick reference.
*/
double FilterWeight() const
{
return m_weight;
}
/*!
* Returns true if the kernel filter currently associated with this
* %Convolution object is a high-pass filter; false if it is a low-pass
* filter. For more information, see the documentation for
* kernelFilter::IsHighPassFilter().
*
* Each time a kernel filter is associated with this object, its high-pass
* nature is checked and stored, along with other filter properties, in
* private data members. This allows for quick lookup of critical filter
* characteristics without degrading performance.
*/
bool IsHighPassFilter() const
{
return m_highPass;
}
/*!
* Returns true iff out-of-range values will be rescaled for normalization of
* images after convolution with a high-pass filter.
*
* A high-pass filter has negative coefficients. As a result, some pixels in
* the convolved image may have negative values. Saturated pixels (values
* above one) can also result, depending on the filter coefficients. The
* standard behavior is to truncate out-of-range pixel values to the [0,1]
* range, which preserves the dynamics of the convolved image, so high-pass
* rescaling is disabled by default. When high-pass rescaling is enabled,
* the resulting image is \e normalized (that is, rescaled to [0,1] only if
* there are out-of-range values) and hence all the data after convolution
* are preserved at the cost of reducing the overall contrast of the image.
* Finally, if <em>raw high-pass convolution</em> has been enabled,
* out-of-range values are neither truncated nor rescaled irrespective of
* the value returned by this function. See the documentation for
* IsRawHighPassEnabled() for more information.
*/
bool IsHighPassRescalingEnabled() const
{
return m_rescaleHighPass;
}
/*!
* Enables (or disables) high-pass rescaling of out-of-range convolved pixel
* values. See the documentation for IsHighPassRescalingEnabled() for more
* information.
*/
void EnableHighPassRescaling( bool enable = true )
{
m_rescaleHighPass = enable;
}
/*!
* Disables (or enables) high-pass rescaling of out-of-range convolved pixel
* values. See the documentation for IsHighPassRescalingEnabled() for more
* information.
*/
void DisableHighPassRescaling( bool disable = true )
{
EnableHighPassRescaling( !disable );
}
/*!
* Returns true iff <em>raw high-pass convolution</em> is enabled. When raw
* high-pass convolution is enabled, out-of-range values after convolution
* with a high-pass filter are neither truncated nor normalized. Note that
* this is only relevant to convolution of floating point data.
*
* Raw high-pass convolution is disabled by default. For more information on
* out-of-range convolution results, refer to the documentation for
* IsHighPassRescalingEnabled().
*/
bool IsRawHighPassEnabled() const
{
return m_rawHighPass;
}
/*!
* Enables (or disables) raw high-pass convolution. See the documentation
* for IsRawHighPassEnabled() for more information.
*/
void EnableRawHighPass( bool enable = true )
{
m_rawHighPass = enable;
}
/*!
* Disables (or enables) raw high-pass convolution. See the documentation
* for IsRawHighPassEnabled() for more information.
*/
void DisableRawHighPass( bool disable = true )
{
EnableRawHighPass( !disable );
}
/*!
* Returns the length in pixels of the overlapping regions between adjacent
* areas processed by parallel execution threads. The overlapping distance
* is a function of the filter size and the interlacing distance.
*/
int OverlappingDistance() const
{
PCL_PRECONDITION( !m_filter.IsNull() )
return m_filter->Size() + (m_filter->Size() - 1)*(InterlacingDistance() - 1);
}
protected:
/*
* The response function for convolution is defined as a kernel filter.
*/
AutoPointer<KernelFilter> m_filter;
/*
* Cached filter properties.
*/
double m_weight = 0; // filter weight for low-pass normalization
bool m_highPass = false; // true if this is a high-pass filter
/*
* User-selectable options
*/
bool m_rawHighPass = false; // neither truncate nor normalize out-of-range values
bool m_rescaleHighPass = false; // truncate out-of-range values instead of normalize
/*
* In-place 2-D nonseparable convolution algorithm in the spatial domain.
*/
void Apply( pcl::Image& ) const override;
void Apply( pcl::DImage& ) const override;
void Apply( pcl::UInt8Image& ) const override;
void Apply( pcl::UInt16Image& ) const override;
void Apply( pcl::UInt32Image& ) const override;
private:
void CacheFilterProperties()
{
PCL_PRECONDITION( !m_filter.IsNull() )
PCL_PRECONDITION( !m_filter->IsEmpty() )
ValidateFilter();
m_highPass = m_filter->IsHighPassFilter();
m_weight = m_filter->Weight();
if ( pcl::Abs( m_weight ) < __PCL_CONVOLUTION_TINY_WEIGHT )
m_weight = 1;
}
void ValidateFilter() const;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_Convolution_h
// ----------------------------------------------------------------------------
// EOF pcl/Convolution.h - Released 2022-03-12T18:59:29Z
-261
View File
@@ -1,261 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Crop.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Crop_h
#define __PCL_Crop_h
/// \file pcl/Crop.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/GeometricTransformation.h>
#include <pcl/ImageResolution.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
\namespace pcl::CropMode
\brief Image cropping modes for the Crop geometric transformation
<table border="1" cellpadding="4" cellspacing="0">
<tr><td>CropMode::RelativeMargins</td> <td>Cropping margins are relative to current image dimensions</td></tr>
<tr><td>CropMode::AbsolutePixels</td> <td>Absolute cropping margins in pixels</td></tr>
<tr><td>CropMode::AbsoluteCentimeters</td> <td>Absolute cropping margins in centimeters</td></tr>
<tr><td>CropMode::AbsoluteInches</td> <td>Absolute cropping margins in inches</td></tr>
</table>
*/
namespace CropMode
{
enum value_type
{
RelativeMargins, // Cropping margins are relative to current image dimensions
AbsolutePixels, // Absolute cropping margins in pixels
AbsoluteCentimeters, // Absolute cropping margins in centimeters
AbsoluteInches // Absolute cropping margins in inches
};
}
// ----------------------------------------------------------------------------
/*!
* \class Crop
* \brief %Image cropping/expansion algorithm
*
* %Crop is a noninterpolating geometric transformation class that allows
* cropping an image or expanding it by specifying separate cropping margins
* for each side. When a cropping margin is negative the image is cropped, and
* when it is positive, the image is expanded.
*/
class PCL_CLASS Crop : public GeometricTransformation,
public ImageResolution
{
public:
/*!
* Represents a cropping mode.
*/
typedef CropMode::value_type crop_mode;
/*!
* Constructs a %Crop object with the specified cropping margins for
* the \a left, \a top, \a right and \a bottom sides.
*/
Crop( double left = 0, double top = 0, double right = 0, double bottom = 0 )
: m_margins( left, top, right, bottom )
, m_mode( CropMode::RelativeMargins )
{
}
/*!
* Constructs a %Crop object whose cropping margins are defined by the
* components of a rectangle \a r.
*/
template <typename T>
Crop( const GenericRectangle<T>& r )
: m_margins( r )
, m_mode( CropMode::RelativeMargins )
{
}
/*!
* Copy constructor.
*/
Crop( const Crop& ) = default;
/*!
* Copy assignment operator. Returns a reference to this object.
*/
Crop& operator =( const Crop& ) = default;
/*!
* Returns a rectangle whose components correspond to the current cropping
* margins of this %Crop object.
*/
DRect Margins() const
{
return m_margins;
}
/*!
* Sets the cropping margins equal to the components of a specified
* rectangle \a r.
*/
template <typename T>
void SetMargins( const GenericRectangle<T>& r )
{
m_margins = r;
}
/*!
* Sets the specified \a left, \a top, \a right and \a bottom cropping
* margins.
*/
void SetMargins( int left, int top, int right, int bottom )
{
m_margins = Rect( left, top, right, bottom );
}
/*!
* Returns the current cropping mode of this %Crop object.
*/
crop_mode Mode() const
{
return m_mode;
}
/*!
* Returns true iff this %Crop object interprets its cropping margins
* relative to current image dimensions. Returns false if cropping margins
* are interpreted as absolute increments.
*/
bool IsRelative() const
{
return m_mode == CropMode::RelativeMargins;
}
/*!
* Returns true iff this %Crop object interprets its cropping margins as
* absolute increments. Returns false if cropping margins are interpreted
* relative to current image dimensions.
*/
bool IsAbsolute() const
{
return !IsRelative();
}
/*!
* Sets the cropping \a mode for this %Crop object.
*/
void SetMode( crop_mode mode )
{
m_mode = mode;
}
/*!
* Returns the current vector of per-channel filling values for uncovered
* image regions.
*
* See the documentation for SetFillValues() for more information.
*/
const DVector& FillValues() const
{
return m_fillValues;
}
/*!
* Sets a vector of per-channel filling values for uncovered image regions.
*
* Uncovered regions result when a %Crop instance extends an image due to
* positive cropping margins.
*
* By default, there are no filling values defined (and hence the returned
* vector is empty by default). When the %Crop instance is executed and a
* filling value is not defined for a channel of the target image, uncovered
* regions are filled with the minimum sample value in the native range of
* the image (usually zero).
*/
void SetFillValues( const DVector& fillValues )
{
m_fillValues = fillValues;
}
/*!
*/
void GetNewSizes( int& width, int& height ) const override;
protected:
DRect m_margins;
crop_mode m_mode;
DVector m_fillValues;
// Inherited from ImageTransformation.
void Apply( pcl::Image& ) const override;
void Apply( pcl::DImage& ) const override;
void Apply( pcl::ComplexImage& ) const override;
void Apply( pcl::DComplexImage& ) const override;
void Apply( pcl::UInt8Image& ) const override;
void Apply( pcl::UInt16Image& ) const override;
void Apply( pcl::UInt32Image& ) const override;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_Crop_h
// ----------------------------------------------------------------------------
// EOF pcl/Crop.h - Released 2022-03-12T18:59:29Z
File diff suppressed because it is too large Load Diff
-357
View File
@@ -1,357 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/CubicSplineInterpolation.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_CubicSplineInterpolation_h
#define __PCL_CubicSplineInterpolation_h
/// \file pcl/CubicSplineInterpolation.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/UnidimensionalInterpolation.h>
namespace pcl
{
// ----------------------------------------------------------------------------
#define m_x this->m_x
#define m_y this->m_y
/*!
* \class CubicSplineInterpolation
* \brief Generic interpolating cubic spline
*
* Interpolation with piecewise cubic polynomials. Spline interpolation is
* usually preferred to interpolation with high-degree polynomials, which are
* subject to oscillations caused by the Runge's phenomenon.
*
* \sa AkimaInterpolation, LinearInterpolation
*/
template <typename T = double>
class PCL_CLASS CubicSplineInterpolation : public UnidimensionalInterpolation<T>
{
public:
typedef typename UnidimensionalInterpolation<T>::vector_type vector_type;
/*!
* Constructs an empty %CubicSplineInterpolation instance, which cannot be
* used for interpolation prior to initialization.
*/
CubicSplineInterpolation() = default;
/*!
* Copy constructor.
*/
CubicSplineInterpolation( const CubicSplineInterpolation& ) = default;
/*!
* Move constructor.
*/
CubicSplineInterpolation( CubicSplineInterpolation&& ) = default;
/*!
* Virtual destructor.
*/
virtual ~CubicSplineInterpolation()
{
}
/*!
* Gets the boundary conditions of this interpolating cubic spline.
*
* \param[out] y1 First derivative of the interpolating cubic spline at
* the first data point x[0].
*
* \param[out] yn First derivative of the interpolating cubic spline at
* the last data point x[n-1].
*/
void GetBoundaryConditions( double& y1, double& yn ) const
{
y1 = m_dy1;
yn = m_dyn;
}
/*!
* Sets the boundary conditions of this interpolating cubic spline.
*
* \param y1 First derivative of the interpolating cubic spline at the
* first data point x[0].
*
* \param yn First derivative of the interpolating cubic spline at the
* last data point x[n-1].
*/
void SetBoundaryConditions( double y1, double yn )
{
Clear();
m_dy1 = y1;
m_dyn = yn;
}
/*!
* Generation of an interpolating cubic spline.
*
* \param x %Vector of x-values:\n
* \n
* \li If \a x is not empty: Must be a vector of monotonically
* increasing, distinct values: x[0] < x[1] < ... < x[n-1].\n
* \li If \a x is empty: This function will generate a natural cubic
* spline with implicit x[i] = i for i = {0,1,...,n-1}.
*
* \param y %Vector of function values for i = {0,1,...,n-1}.
*
* When \a x is an empty vector, a <em>natural spline</em> is always
* generated: boundary conditions are ignored and taken as zero at both ends
* of the data sequence.
*
* The length of the \a y vector (and also the length of a nonempty \a x
* vector) must be \e n >= 2.
*/
void Initialize( const vector_type& x, const vector_type& y ) override
{
if ( y.Length() < 2 )
throw Error( "CubicSplineInterpolation::Initialize(): Less than two data points specified." );
try
{
Clear();
UnidimensionalInterpolation<T>::Initialize( x, y );
int n = this->Length();
m_dy2 = DVector( n );
m_current = -1; // prepare for 1st interpolation
DVector w( n ); // working vector
if ( m_x )
{
/*
* Cubic splines with explicit x[i] for i = {0,...,n-1}.
*/
if ( m_dy1 == 0 && m_dyn == 0 )
{
/*
* Natural cubic spline.
*/
m_dy2[0] = m_dy2[n-1] = w[0] = 0;
for ( int i = 1; i < n-1; ++i )
{
double s = (double( m_x[i] ) - double( m_x[i-1] )) / (double( m_x[i+1] ) - double( m_x[i-1] ));
double p = s*m_dy2[i-1] + 2;
m_dy2[i] = (s - 1)/p;
w[i] = (double( m_y[i+1] ) - double( m_y[i ] )) / (double( m_x[i+1] ) - double( m_x[i ] ))
- (double( m_y[i ] ) - double( m_y[i-1] )) / (double( m_x[i ] ) - double( m_x[i-1] ));
w[i] = (6*w[i]/(double( m_x[i+1] ) - double( m_x[i-1] )) - s*w[i-1])/p;
}
for ( int i = n-2; i > 0; --i ) // N.B. w[0] is not defined
m_dy2[i] = m_dy2[i]*m_dy2[i+1] + w[i];
}
else
{
/*
* Cubic spline with prescribed end point derivatives.
*/
w[0] = 3/(double( m_x[1] ) - double( m_x[0] ))
* ((double( m_y[1] ) - double( m_y[0] ))/(double( m_x[1] ) - double( m_x[0] )) - m_dy1);
m_dy2[0] = -0.5;
for ( int i = 1; i < n-1; ++i )
{
double s = (double( m_x[i] ) - double( m_x[i-1] )) / (double( m_x[i+1] ) - double( m_x[i-1] ));
double p = s*m_dy2[i-1] + 2;
m_dy2[i] = (s - 1)/p;
w[i] = (double( m_y[i+1] ) - double( m_y[i ] )) / (double( m_x[i+1] ) - double( m_x[i ] ))
- (double( m_y[i ] ) - double( m_y[i-1] )) / (double( m_x[i ] ) - double( m_x[i-1] ));
w[i] = (6*w[i]/(double( m_x[i+1] ) - double( m_x[i-1] )) - s*w[i-1])/p;
}
m_dy2[n-1] = (3/(double( m_x[n-1] ) - double( m_x[n-2] ))
* (m_dyn - (double( m_y[n-1] ) - double( m_y[n-2] ))/(double( m_x[n-1] ) - double( m_x[n-2] ))) - w[n-2]/2)
/ (1 + m_dy2[n-2]/2);
for ( int i = n-2; i >= 0; --i )
m_dy2[i] = m_dy2[i]*m_dy2[i+1] + w[i];
}
}
else
{
/*
* Natural cubic spline with
* implicit x[i] = i for i = {0,1,...,n-1}.
*/
m_dy2[0] = m_dy2[n-1] = w[0] = 0;
for ( int i = 1; i < n-1; ++i )
{
double p = m_dy2[i-1]/2 + 2;
m_dy2[i] = -0.5/p;
w[i] = double( m_y[i+1] ) - 2*double( m_y[i] ) + double( m_y[i-1] );
w[i] = (3*w[i] - w[i-1]/2)/p;
}
for ( int i = n-2; i > 0; --i ) // N.B. w[0] is not defined
m_dy2[i] = m_dy2[i]*m_dy2[i+1] + w[i];
}
}
catch ( ... )
{
Clear();
throw;
}
}
/*!
* Cubic spline interpolation. Returns an interpolated value at the
* specified point \a x.
*/
double operator()( double x ) const override
{
PCL_PRECONDITION( IsValid() )
int n = this->Length();
if ( m_x )
{
/*
* Cubic spline with explicit x[i] for i = {0,...,n-1}.
*/
/*
* Bracket the evaluation point x by binary search of the closest
* pair of data points, if needed. m_current < 0 signals first-time
* evaluation since initialization.
*/
int j0 = m_current, j1;
if ( j0 < 0 || x < m_x[j0] || m_x[j0+1] < x )
for ( j0 = 0, j1 = n-1; j1-j0 > 1; )
{
int m = (j0 + j1) >> 1;
if ( x < m_x[m] )
j1 = m;
else
j0 = m;
}
else
j1 = j0 + 1;
m_current = j0;
/*
* Distance h between the closest neighbors. Will be zero (or
* insignificant) if two or more x values are equal with respect to
* the machine epsilon for type T.
*/
double h = double( m_x[j1] ) - double( m_x[j0] );
if ( 1 + h == 1 )
return 0.5*(double( m_y[j0] ) + double( m_y[j1] ));
double a = (double( m_x[j1] ) - x)/h;
double b = (x - double( m_x[j0] ))/h;
return a*double( m_y[j0] )
+ b*double( m_y[j1] )
+ ((a*a*a - a)*m_dy2[j0] + (b*b*b - b)*m_dy2[j1])*h*h/6;
}
else
{
/*
* Natural cubic spline with implicit x[i] = i for i = {0,1,...,n-1}.
*/
int j0 = pcl::Range( pcl::TruncInt( x ), 0, n-1 );
int j1 = pcl::Min( n-1, j0+1 );
double a = j1 - x;
double b = x - j0;
return a*double( m_y[j0] )
+ b*double( m_y[j1] )
+ ((a*a*a - a)*m_dy2[j0] + (b*b*b - b)*m_dy2[j1])/6;
}
}
/*!
* Resets this cubic spline interpolation, deallocating all internal
* working structures.
*/
void Clear() override
{
UnidimensionalInterpolation<T>::Clear();
m_dy2.Clear();
}
/*!
* Returns true iff this interpolation is valid, i.e. if it has been
* correctly initialized and is ready to interpolate function values.
*/
bool IsValid() const override
{
return m_dy2;
}
private:
double m_dy1 = 0; // 1st derivative of spline at the first data point
double m_dyn = 0; // 1st derivative of spline at the last data point
DVector m_dy2; // second derivatives of the interpolating function at x[i]
mutable int m_current = -1; // index of the current interpolation segment
};
#undef m_x
#undef m_y
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_CubicSplineInterpolation_h
// ----------------------------------------------------------------------------
// EOF pcl/CubicSplineInterpolation.h - Released 2022-03-12T18:59:29Z
-297
View File
@@ -1,297 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Cursor.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Cursor_h
#define __PCL_Cursor_h
/// \file pcl/Cursor.h
#include <pcl/Defs.h>
#include <pcl/Point.h>
#include <pcl/UIObject.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::StdCursor
* \brief Standard cursor shapes available in the PixInsight core application
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>StdCursor::NoCursor</td> <td>No cursor is shown</td></tr>
* <tr><td>StdCursor::Arrow</td> <td>Standard arrow cursor (pointing left)</td></tr>
* <tr><td>StdCursor::InvArrow</td> <td>Inverted arrow cursor (pointing right)</td></tr>
* <tr><td>StdCursor::UpArrow</td> <td>Upwards arrow</td></tr>
* <tr><td>StdCursor::DownArrow</td> <td>Downwards arrow</td></tr>
* <tr><td>StdCursor::LeftArrow</td> <td>Leftwards arrow</td></tr>
* <tr><td>StdCursor::RightArrow</td> <td>Rightwards arrow</td></tr>
* <tr><td>StdCursor::Checkmark</td> <td>Checkmark (ok) cursor</td></tr>
* <tr><td>StdCursor::Crossmark</td> <td>Crossmark (cancel) cursor</td></tr>
* <tr><td>StdCursor::Accept</td> <td>Arrow + checkmark</td></tr>
* <tr><td>StdCursor::Reject</td> <td>Arrow + crossmark</td></tr>
* <tr><td>StdCursor::Add</td> <td>Arrow + plus sign</td></tr>
* <tr><td>StdCursor::Copy</td> <td>Arrow + square</td></tr>
* <tr><td>StdCursor::Cross</td> <td>Crosshair</td></tr>
* <tr><td>StdCursor::Hourglass</td> <td>Hourglass (native Windows wait cursor)</td></tr>
* <tr><td>StdCursor::Watch</td> <td>Watch (native Macintosh wait cursor)</td></tr>
* <tr><td>StdCursor::Wait</td> <td>Default wait cursor (same as StdCursor::Watch)</td></tr>
* <tr><td>StdCursor::ArrowWait</td> <td>Arrow + hourglass/watch</td></tr>
* <tr><td>StdCursor::ArrowQuestion</td> <td>Arrow + question mark</td></tr>
* <tr><td>StdCursor::IBeam</td> <td>I-beam cursor (text edition)</td></tr>
* <tr><td>StdCursor::VerticalSize</td> <td>Vertical resize</td></tr>
* <tr><td>StdCursor::HorizontalSize</td> <td>Horizontal resize</td></tr>
* <tr><td>StdCursor::ForwardDiagonalSize</td> <td>Forward diagonal resize (/)</td></tr>
* <tr><td>StdCursor::BackwardDiagonalSize</td> <td>Backward diagonal resize (\\)</td></tr>
* <tr><td>StdCursor::SizeAll</td> <td>Resize in all directions</td></tr>
* <tr><td>StdCursor::VerticalSplit</td> <td>Split vertical</td></tr>
* <tr><td>StdCursor::HorizontalSplit</td> <td>Split horizontal</td></tr>
* <tr><td>StdCursor::Hand</td> <td>Pointing hand cursor</td></tr>
* <tr><td>StdCursor::PointingHand</td> <td>Pointing hand cursor (same as StdCursor::Hand)</td></tr>
* <tr><td>StdCursor::OpenHand</td> <td>Open hand cursor (used to inform about dragging operations)</td></tr>
* <tr><td>StdCursor::ClosedHand</td> <td>Closed hand cursor (used during active dragging operations)</td></tr>
* <tr><td>StdCursor::SquarePlus</td> <td>Plus sign into a square (used for zooming in)</td></tr>
* <tr><td>StdCursor::SquareMinus</td> <td>Minus sign into a square (used for zooming out)</td></tr>
* <tr><td>StdCursor::CirclePlus</td> <td>Plus sign into a circle (used for zooming in)</td></tr>
* <tr><td>StdCursor::CircleMinus</td> <td>Minus sign into a circle (used for zooming out)</td></tr>
* <tr><td>StdCursor::Forbidden</td> <td>Stop cursor</td></tr>
* </table>
*/
namespace StdCursor
{
enum value_type
{
NoCursor, // no cursor is shown
Arrow, // standard arrow cursor (pointing left)
InvArrow, // inverted arrow cursor (pointing right)
UpArrow, // upwards arrow
DownArrow, // downwards arrow
LeftArrow, // leftwards arrow
RightArrow, // rightwards arrow
Checkmark, // checkmark (ok) cursor
Crossmark, // crossmark (cancel) cursor
Accept, // arrow + checkmark
Reject, // arrow + crossmark
Add, // arrow + plus sign
Copy, // arrow + square
Cross, // crosshair
Hourglass, // hourglass (native Windows wait cursor)
Watch, // watch (native Macintosh wait cursor)
Wait = Watch, // wait cursor: we like the watch! :)
ArrowWait, // arrow + hourglass/watch
ArrowQuestion, // arrow + question mark
IBeam, // I-beam cursor (text edition)
VerticalSize, // vertical resize
HorizontalSize, // horizontal resize
ForwardDiagonalSize, // forward diagonal resize (/)
BackwardDiagonalSize, // backward diagonal resize (\)
SizeAll, // resize in all directions
VerticalSplit, // split vertical
HorizontalSplit, // split horizontal
Hand, // pointing hand cursor
PointingHand = Hand, // pointing hand cursor (same as Hand)
OpenHand, // open hand cursor
ClosedHand, // closed hand cursor
SquarePlus, // plus sign into a square (used for zoom in)
SquareMinus, // minus sign into a square (used for zoom out)
CirclePlus, // plus sign into a circle (used for zoom in)
CircleMinus, // minus sign into a circle (used for zoom out)
Forbidden // stop cursor
};
}
// ----------------------------------------------------------------------------
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
class Bitmap;
// ----------------------------------------------------------------------------
/*!
* \class Cursor
* \brief Client-side interface to a PixInsight %Cursor object
*
* ### TODO: Write a detailed description for %Cursor.
*/
class PCL_CLASS Cursor : public UIObject
{
public:
/*!
* Represents a standard cursor shape.
*/
typedef StdCursor::value_type std_cursor;
/*!
* Constructs a %Cursor object with the specified standard cursor \a shape.
*/
Cursor( std_cursor shape = StdCursor::Arrow );
/*!
* Constructs a %Cursor object with the specified \a bmp shape and
* hot spot coordinates \a hotSpot.
*/
Cursor( const Bitmap& bmp, const pcl::Point& hotSpot );
/*!
* Constructs a %Cursor object with the specified \a bmp shape and
* hot spot coordinates \a hotSpotX and \a hotSpotY.
*/
Cursor( const Bitmap& bmp, int hotSpotX = 0, int hotSpotY = 0 );
/*!
* Copy constructor. This object will reference the same server-side cursor
* as the specified instance \a c.
*/
Cursor( const Cursor& c ) : UIObject( c )
{
}
/*!
* Move constructor.
*/
Cursor( Cursor&& x ) : UIObject( std::move( x ) )
{
}
/*!
* Destroys a %Cursor object. If this object references an existing cursor
* in the PixInsight core application, its reference count is decremented.
* If it becomes unreferenced, it will be garbage-collected.
*/
virtual ~Cursor()
{
}
/*!
* Copy assignment operator. Returns a reference to this object.
*
* Makes this object reference the same server-side cursor as the specified
* instance \a c. If the previous cursor becomes unreferenced, it will be
* garbage-collected by the PixInsight core application.
*/
Cursor& operator =( const Cursor& c )
{
SetHandle( c.handle );
return *this;
}
/*!
* Move assignment operator. Returns a reference to this object.
*/
Cursor& operator =( Cursor&& x )
{
Transfer( x );
return *this;
}
/*!
* Returns a reference to a <em>null cursor</em>. A null %Cursor object does
* not correspond to an existing cursor object in the PixInsight core
* application.
*/
static Cursor& Null();
/*!
* Returns the hot spot coordinates of this %Cursor object.
*
* The hot spot is the <em>active point</em> of the cursor. It is used by
* the operating system to calculate the current cursor position. Hot spot
* coordinates are given relative to the upper left corner of the cursor's
* shape bitmap.
*/
pcl::Point HotSpot() const;
/*!
* Returns the current cursor position in global coordinates.
*/
static pcl::Point Position();
/*!
* Sets the current cursor position to the specified \a x and \a y global
* coordinates.
*/
static void SetPosition( int x, int y );
/*!
* Sets the current cursor position in global coordinates.
*
* This function is equivalent to SetPosition( pos.x, pos.y ).
*/
static void SetPosition( const pcl::Point& pos )
{
SetPosition( pos.x, pos.y );
}
private:
Cursor( void* h ) : UIObject( h )
{
}
void* CloneHandle() const override;
friend class Control;
};
// ----------------------------------------------------------------------------
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
} // pcl
#endif // __PCL_Cursor_h
// ----------------------------------------------------------------------------
// EOF pcl/Cursor.h - Released 2022-03-12T18:59:29Z
-1206
View File
File diff suppressed because it is too large Load Diff
-130
View File
@@ -1,130 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Diagnostics.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Diagnostics_h
#define __PCL_Diagnostics_h
#include <pcl/Defs.h>
namespace pcl
{
// ----------------------------------------------------------------------------
// Definitions and macros for implementation of diagnostics code.
// ----------------------------------------------------------------------------
// ###### THIS HEADER IS FOR INTERNAL USE EXCLUSIVELY - PLEASE IGNORE IT ######
// ----------------------------------------------------------------------------
bool PCL_FUNC IsConsoleDiagnostics();
void PCL_FUNC SetConsoleDiagnostics( bool set = true );
inline void SetGUIDiagnostics( bool set = true )
{
SetConsoleDiagnostics( !set );
}
} // pcl
extern "C" void PCL_FUNC __PCLAssertFail( int, const char*, const char*, int );
#define __PCL_ASSERTION 0
#define __PCL_PRECONDITION 1
#define __PCL_CHECK 2
// ----------------------------------------------------------------------------
// The value of __PCL_DIAGNOSTICS_LEVEL controls generation of diagnostics
// code, as follows:
// 0 = no diagnostics code is generated (the default value)
// 1 = CHECK code only
// 2 = both CHECK and PRECONDITION code
// ----------------------------------------------------------------------------
#ifndef __PCL_DIAGNOSTICS_LEVEL
#define __PCL_DIAGNOSTICS_LEVEL 0
#endif
// ----------------------------------------------------------------------------
// Precondition diagnostics macro.
// This macro must be used when the arguments of a function are required to
// satisfy a given condition p. The default behavior, under diagnostics mode,
// is to terminate program execution if p doesn't hold.
// ----------------------------------------------------------------------------
#if __PCL_DIAGNOSTICS_LEVEL > 1
#define PCL_PRECONDITION( __p ) \
((__p) ? (void)0 : \
(void)__PCLAssertFail( __PCL_PRECONDITION, #__p, __FILE__, __LINE__ ));
#else
#define PCL_PRECONDITION( __p )
#endif
// ----------------------------------------------------------------------------
// Check diagnostics macro.
// This macro should be used at any point where execution cannot continue if a
// given condition p is not satisfied, except when a precondition applies. The
// default behavior is to terminate program execution if p doesn't hold.
// ----------------------------------------------------------------------------
#if __PCL_DIAGNOSTICS_LEVEL > 0
#define PCL_CHECK( __p ) \
((__p) ? (void)0 : \
(void)__PCLAssertFail( __PCL_CHECK, #__p, __FILE__, __LINE__ ));
#else
#define PCL_CHECK( __p )
#endif
// ----------------------------------------------------------------------------
#endif // __PCL_Diagnostics_h
// ----------------------------------------------------------------------------
// EOF pcl/Diagnostics.h - Released 2022-03-12T18:59:29Z
-309
View File
@@ -1,309 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Dialog.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Dialog_h
#define __PCL_Dialog_h
/// \file pcl/Dialog.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/AutoPointer.h>
#include <pcl/Control.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::StdDialogCode
* \brief Standard dialog return codes
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>StdDialogCode::Ok</td> <td>The dialog has been accepted (e.g., by clicking the OK button)</td></tr>
* <tr><td>StdDialogCode::Cancel</td> <td>The dialog has been rejected (e.g., by clicking the Cancel button)</td></tr>
* </table>
*/
namespace StdDialogCode
{
enum value_type
{
Cancel = 0, // The dialog has been rejected (e.g., by clicking the Cancel button)
Ok = 1 // The dialog has been accepted (e.g., by clicking the OK button)
};
}
// ----------------------------------------------------------------------------
/*!
* \class Dialog
* \brief Client-side interface to a PixInsight modal dialog
*
* Dialogs are top-level windows that execute modally relative to the main
* window of the PixInsight core application.
*/
class PCL_CLASS Dialog : public Control
{
public:
/*!
* Represents a standard dialog return code.
*/
typedef StdDialogCode::value_type std_code;
/*!
* Constructs a %Dialog object.
*
* If the specified \a parent control is a non-null control, the dialog will
* be shown centered over its parent. Otherwise the dialog window will be
* shown centered on the current workspace. Note that specifying a dialog
* parent does not change the dialog's \e modality: all dialog windows are
* application-modal in PixInsight. See the Execute() and Open() member
* functions for more information.
*/
Dialog( Control& parent = Control::Null() );
/*!
* Destroys a %Dialog object.
*/
virtual ~Dialog()
{
}
/*!
* Shows a modal dialog and executes a separate event loop.
*
* This function creates a new event loop and does not return until the loop
* has exited and the dialog has been closed. During the event loop, the
* dialog behaves as an <em>application modal window:</em> Only the dialog
* window allows user interaction while the rest of the GUI is blocked in
* the PixInsight core application. To exit the modal event loop, the Ok()
* and Cancel() member functions can be used to return the standard dialog
* exit codes StdDialogCode::Ok and StdDialogCode::Cancel, respectively.
*
* This function returns a <em>dialog return code</em>. Although dialog
* return codes are arbitrary (they can be forced to any integer value with
* the Return() member function), dialogs with standard OK and Cancel
* buttons should always return a standard code, as defined in the
* StdDialogCode namespace.
*
* For a non-blocking alternative to use dialog windows, see the Open()
* member function.
*
* \sa Ok(), Cancel(), Return(), Open()
*/
int Execute();
/*!
* Shows a modal dialog window.
*
* This function opens the dialog window and returns immediately, allowing
* normal execution to continue without entering a separate event loop. As
* happens with Dialog::Execute(), this member function creates a modal
* dialog that blocks the rest of the PixInsight core application for GUI
* user interaction. The essential difference between both member functions
* is that Open() does not enter a new event loop. Typically, this function
* is used to provide feedback to the user during long procedures, as well
* as the possibility to interrupt or pause those procedures. For example,
* a <em>progress dialog</em> can be shown as a modal window during a file
* copy operation, or while a long calculation routine is being executed.
*
* \sa Execute()
*/
void Open();
/*!
* Closes this modal dialog and forces a return value \a retCode for the
* Execute() member function.
*/
void Return( int retCode );
/*!
* This is a convenience member function equivalent to:\n
* Return( StdDialogCode::Ok )
*/
void Ok()
{
Return( StdDialogCode::Ok );
}
/*!
* This is a convenience member function equivalent to:\n
* Return( StdDialogCode::Cancel )
*/
void Cancel()
{
Return( StdDialogCode::Cancel );
}
/*!
* Returns true iff this dialog is user-resizable. User-resizable dialogs can
* be resized interactively with the mouse and standard window controls.
*/
bool IsUserResizable() const;
/*!
* Enables or disables user resizing for this dialog.
*/
void EnableUserResizing( bool = true );
/*!
* Disables or enables user resizing for this dialog.
*
* This is a convenience member function, equivalent to:
* EnableUserResizing( !disable )
*/
void DisableUserResizing( bool disable = true )
{
EnableUserResizing( !disable );
}
/*!
* Processes pending user interface events.
*
* This member function is a convenience wrapper with the same functionality
* as ProcessInterface::ProcessEvents().
*/
static void ProcessEvents( bool excludeUserInputEvents = false );
// -------------------------------------------------------------------------
// Event handlers
//
// void OnExecute( Dialog& sender );
// void OnReturn( Dialog& sender, int retVal );
/*!
* \defgroup dialog_event_handlers Dialog Event Handlers
*/
/*!
* Defines the prototype of a <em>dialog execution</em> event handler.
*
* A dialog execution event is generated when a dialog control is executed
* by invoking its Execute() member function.
*
* \param sender The dialog that sends an execution event.
*
* \ingroup dialog_event_handlers
*/
typedef void (Control::*execute_event_handler)( Dialog& sender );
/*!
* Defines the prototype of a <em>dialog return</em> event handler.
*
* A dialog return event is generated when a dialog control terminates
* execution by invoking its Return() member function.
*
* \param sender The dialog that sends a return event.
*
* \param retCode Return code passed to the Return() member function. This
* is also the return value of Execute().
*
* \ingroup dialog_event_handlers
*/
typedef void (Control::*return_event_handler)( Dialog& sender, int retCode );
/*!
* Sets the execution event handler for this dialog.
*
* \param handler The dialog execution event handler. Must be a member
* function of the receiver object's class.
*
* \param receiver The control that will receive execution events from
* this dialog.
*
* \ingroup dialog_event_handlers
*/
void OnExecute( execute_event_handler handler, Control& receiver );
/*!
* Sets the return event handler for this dialog.
*
* \param handler The dialog return event handler. Must be a member
* function of the receiver object's class.
*
* \param receiver The control that will receive return events from this
* dialog.
*
* \ingroup dialog_event_handlers
*/
void OnReturn( return_event_handler handler, Control& receiver );
private:
struct EventHandlers
{
execute_event_handler onExecute = nullptr;
return_event_handler onReturn = nullptr;
EventHandlers() = default;
EventHandlers( const EventHandlers& ) = default;
EventHandlers& operator =( const EventHandlers& ) = default;
};
AutoPointer<EventHandlers> m_handlers;
friend class DialogEventDispatcher;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
#endif // __PCL_Dialog_h
// ----------------------------------------------------------------------------
// EOF pcl/Dialog.h - Released 2022-03-12T18:59:29Z
-463
View File
@@ -1,463 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/DisplayFunction.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_DisplayFunction_h
#define __PCL_DisplayFunction_h
/// \file pcl/DisplayFunction.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/HistogramTransformation.h>
#include <pcl/Vector.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*
* Default clipping increment in sigma units.
*/
#define __PCL_AUTOSTRETCH_DEFAULT_CLIP -2.80
/*
* Default target mean background in the [0,1] range.
*/
#define __PCL_AUTOSTRETCH_DEFAULT_TBGD 0.25
/*
* Whether to apply a single transformation to nominal RGB channels, or
* separate per-channel transformations.
*/
#define __PCL_AUTOSTRETCH_DEFAULT_LINK false
// ----------------------------------------------------------------------------
/*!
* \class DisplayFunction
* \brief Adaptive histogram transformations for image visualization.
*
* %DisplayFunction implements a set of histogram transformations for
* visualization of linear images.
*/
class PCL_CLASS DisplayFunction : public ImageTransformation
{
public:
/*!
* Default constructor. Constructs an identity display function.
*/
DisplayFunction()
: m_m( 4 ), m_s( 4 ), m_h( 4 ), m_l( 4 ), m_r( 4 )
{
Reset();
}
/*!
* Constructs a display function with the specified parameters.
*
* \param m Vector of midtones balance parameters.
* \param s Vector of shadows clipping point parameters.
* \param h Vector of highlights clipping point parameters.
* \param l Vector of shadows dynamic range expansion parameters.
* \param r Vector of highlights dynamic range expansion parameters.
*
* Each argument vector can have from zero to four components (additional
* vector components are ignored, and missing components are replaced with
* default identity transformation parameters). Vector indices 0, 1, 2 and 3
* correspond to the red/gray, green, blue and lightness components for
* histogram transformations.
*
* For detailed information on parameter values and valid ranges, see the
* HistogramTransformation class.
*/
template <class V>
DisplayFunction( const V& m, const V& s, const V& h, const V& l = V(), const V& r = V() )
: m_m( 4 ), m_s( 4 ), m_h( 4 ), m_l( 4 ), m_r( 4 )
{
Reset();
for ( int i = 0; i < 4 && i < int( m.Length() ); ++i ) m_m[i] = Range( double( m[i] ), 0.0, 1.0 );
for ( int i = 0; i < 4 && i < int( s.Length() ); ++i ) m_s[i] = Range( double( s[i] ), 0.0, 1.0 );
for ( int i = 0; i < 4 && i < int( h.Length() ); ++i ) m_h[i] = Range( double( h[i] ), 0.0, 1.0 );
for ( int i = 0; i < 4 && i < int( l.Length() ); ++i ) m_l[i] = Max( 0.0, double( l[i] ) );
for ( int i = 0; i < 4 && i < int( r.Length() ); ++i ) m_r[i] = Min( 1.0, double( r[i] ) );
for ( int i = 0; i < 4; ++i )
if ( m_h[i] < m_s[i] )
pcl::Swap( m_s[i], m_h[i] );
}
/*!
* Copy constructor.
*/
DisplayFunction( const DisplayFunction& ) = default;
/*!
* Move constructor.
*/
DisplayFunction( DisplayFunction&& ) = default;
/*!
* Copy assignment operator. Returns a reference to this object.
*/
DisplayFunction& operator =( const DisplayFunction& ) = default;
/*!
* Move assignment operator. Returns a reference to this object.
*/
DisplayFunction& operator =( DisplayFunction&& ) = default;
/*!
* Virtual destructor.
*/
virtual ~DisplayFunction()
{
}
/*!
* Array subscript operator. Returns an histogram transformation for the
* specified channel index \a i, which must be in the range [0,3].
*
* Channel indices 0, 1, 2 and 3 correspond to the red/gray, green, blue and
* lightness components, respectively. If an out-of-range channel index is
* specified, this operator returns an identity histogram transformation.
*/
HistogramTransformation operator []( int i ) const
{
PCL_PRECONDITION( 0 <= i && i < 4 )
PCL_CHECK( m_m.Length() == 4 && m_s.Length() == 4 && m_h.Length() == 4 && m_l.Length() == 4 && m_r.Length() == 4 )
if ( i >= 0 && i < 4 )
return HistogramTransformation( m_m[i], m_s[i], m_h[i], m_l[i], m_r[i] );
return HistogramTransformation();
}
/*!
* Returns a dynamic array of histogram transformations.
*
* The returned object contains four HistogramTransformation instances,
* where array indexes 0, 1, 2 and 3 correspond to the red/gray, green, blue
* and lightness components, respectively.
*/
Array<HistogramTransformation> HistogramTransformations() const
{
return Array<HistogramTransformation>() << operator[]( 0 )
<< operator[]( 1 )
<< operator[]( 2 )
<< operator[]( 3 );
}
/*!
* Gets a copy of all display function parameters in the specified vectors.
*
* \param[out] m Vector of midtones balance parameters.
* \param[out] s Vector of shadows clipping point parameters.
* \param[out] h Vector of highlights clipping point parameters.
* \param[out] l Vector of shadows dynamic range expansion parameters.
* \param[out] r Vector of highlights dynamic range expansion parameters.
*
* On output, each vector will have four components with the histogram
* transformation parameters for the red/gray, green, blue and lightness
* image components at vector indexes 0, 1, 2 and 3, respectively.
*/
template <class V>
void GetDisplayFunctionParameters( V& m, V& s, V& h, V& l, V& r ) const
{
m = m_m; s = m_s; h = m_h; l = m_l; r = m_r;
}
/*!
* Returns true only if this object defines an identity display function for
* the specified channel index \a i.
*
* An identity display function is a no-op: it does not alter the pixel data
* or properties of the target images to which it is applied.
*/
bool IsIdentityTransformation( int i ) const
{
PCL_PRECONDITION( 0 <= i && i < 4 )
PCL_CHECK( m_m.Length() == 4 && m_s.Length() == 4 && m_h.Length() == 4 && m_l.Length() == 4 && m_r.Length() == 4 )
return i >= 0 && i < 4 && m_m[i] == 0.5 && m_s[i] == 0 && m_h[i] == 1 && m_l[i] == 0 && m_r[i] == 1;
}
/*!
* Returns true iff this is an identity display function for the four
* image components (red/gray, green, blue and lightness).
*
* An identity display function is a no-op: it does not alter the pixel data
* or properties of the target images to which it is applied.
*/
bool IsIdentityTransformation() const
{
return IsIdentityTransformation( 0 )
&& IsIdentityTransformation( 1 )
&& IsIdentityTransformation( 2 )
&& IsIdentityTransformation( 3 );
}
/*!
* Returns the clipping point parameter of this transformation, in sigma
* units from the central value.
*/
double ClippingPoint() const
{
return m_clip;
}
/*!
* Sets the clipping point parameter of this transformation, in sigma units
* from the central value. The default clipping point is -2.8.
*/
void SetClippingPoint( double clip )
{
m_clip = clip;
}
/*!
* Returns the target background parameter of this transformation in the
* normalized [0,1] range.
*/
double TargetBackground() const
{
return m_tbkg;
}
/*
* Sets the target background parameter of this transformation in the
* normalized [0,1] range. The default target background is 0.25.
*/
void SetTargetBackground( double tbkg )
{
m_tbkg = Range( tbkg, 0.0, 1.0 );
}
/*!
* Returns true iff this transformation will compute a single adaptive
* histogram transformation for the nominal channels of an RGB color image.
* Returns false if adaptive per-channel transformations will be calculated
* separately.
*/
bool LinkedRGB() const
{
return m_link;
}
/*!
* Sets the 'linked RGB' parameter of this transformation. When this
* parameter is true, a single adaptive histogram transformation will be
* computed for the nominal channels of an RGB color image. When this
* parameter is false, separate adaptive transformations will be calculated
* for each channel.
*/
void SetLinkedRGB( bool link = true )
{
m_link = link;
}
/*!
* Computes adaptive display functions, also known as <em>auto-stretch
* functions</em>, based on statistical estimates of scale and location.
*
* \param sigma Vector of scale estimates. This is typically a vector of
* normalized MAD values (median absolute deviation from the
* median) or similar robust dispersion estimates.
*
* \param center Vector of location estimates. Typically the median is used
* as a robust estimator of central tendency.
*
* Both vectors must have one or three components, respectively for a
* monochrome (grayscale) or RGB color image. Avoid using non-robust
* statistical estimators such as the standard deviation or the mean, which
* can easily lead to completely wrong results.
*
* To obtain results coherent with other implementations, scale estimates
* should be normalized to be consistent with the standard deviation of a
* normal distribution. For example, if MAD values are used, they should be
* multiplied by 1.4826 before calling this function.
*/
template <class V>
void ComputeAutoStretch( const V& sigma, const V& center )
{
PCL_CHECK( m_m.Length() == 4 && m_s.Length() == 4 && m_h.Length() == 4 && m_l.Length() == 4 && m_r.Length() == 4 )
if ( sigma.IsEmpty() || center.IsEmpty() )
{
Reset();
return;
}
int n = (sigma.Length() < 3 || center.Length() < 3) ? 1 : 3;
if ( m_link )
{
/*
* Try to find out how many channels look like channels of an inverted
* image.
*
* We know a channel is inverted because the main histogram peak is
* located over the right-hand half of the histogram. Seems simplistic
* but this is consistent with most real-world images.
*/
int invertedChannels = 0;
for ( int i = 0; i < n; ++i )
if ( center[i] > 0.5 )
++invertedChannels;
double c = 0, m = 0;
if ( invertedChannels < n )
{
// Noninverted image
for ( int i = 0; i < n; ++i )
{
if ( 1 + sigma[i] != 1 )
c += center[i] + m_clip * sigma[i];
m += center[i];
}
m_s[0] = m_s[1] = m_s[2] = Range( c/n, 0.0, 1.0 );
m_m[0] = m_m[1] = m_m[2] = HistogramTransformation::MTF( m_tbkg, m/n - m_s[0] );
m_l[0] = m_l[1] = m_l[2] = 0.0;
m_h[0] = m_h[1] = m_h[2] = m_r[0] = m_r[1] = m_r[2] = 1.0;
}
else
{
// Inverted image
for ( int i = 0; i < n; ++i )
{
c += (1 + sigma[i] != 1) ? center[i] - m_clip * sigma[i] : 1.0;
m += center[i];
}
m_h[0] = m_h[1] = m_h[2] = Range( c/n, 0.0, 1.0 );
m_m[0] = m_m[1] = m_m[2] = HistogramTransformation::MTF( m_h[0] - m/n, m_tbkg );
m_s[0] = m_s[1] = m_s[2] = m_l[0] = m_l[1] = m_l[2] = 0.0;
m_r[0] = m_r[1] = m_r[2] = 1.0;
}
}
else
{
/*
* Unlinked RGB/K channnels: Compute automatic stretch functions for
* individual RGB/K channels separately.
*/
for ( int i = 0; i < n; ++i )
if ( center[i] < 0.5 )
{
// Noninverted channel
m_s[i] = (1 + sigma[i] != 1) ? Range( center[i] + m_clip * sigma[i], 0.0, 1.0 ) : 0.0;
m_m[i] = HistogramTransformation::MTF( m_tbkg, center[i] - m_s[i] );
m_l[i] = 0.0;
m_h[i] = m_r[i] = 1.0;
}
else
{
// Inverted channel
m_h[i] = (1 + sigma[i] != 1) ? Range( center[i] - m_clip * sigma[i], 0.0, 1.0 ) : 1.0;
m_m[i] = HistogramTransformation::MTF( m_h[i] - center[i], m_tbkg );
m_s[i] = m_l[i] = 0.0;
m_r[i] = 1.0;
}
}
}
/*!
* Resets all display function parameters to yield an identity
* transformation.
*/
void Reset()
{
m_m = 0.5;
m_s = m_l = 0.0;
m_h = m_r = 1.0;
}
/*!
* Exchanges two %DisplayFunction objects.
*/
friend void Swap( DisplayFunction& x, DisplayFunction& y )
{
pcl::Swap( x.m_m, y.m_m );
pcl::Swap( x.m_s, y.m_s );
pcl::Swap( x.m_h, y.m_h );
pcl::Swap( x.m_l, y.m_l );
pcl::Swap( x.m_r, y.m_r );
pcl::Swap( x.m_clip, y.m_clip );
pcl::Swap( x.m_tbkg, y.m_tbkg );
pcl::Swap( x.m_link, y.m_link );
}
private:
DVector m_m; // midtones balance
DVector m_s; // shadows clipping point
DVector m_h; // highlights clipping point
DVector m_l; // shadows dynamic range expansion
DVector m_r; // highlights dynamic range expansion
double m_clip = __PCL_AUTOSTRETCH_DEFAULT_CLIP; // auto-stretch clipping point
double m_tbkg = __PCL_AUTOSTRETCH_DEFAULT_TBGD; // auto-stretch target background
bool m_link = __PCL_AUTOSTRETCH_DEFAULT_LINK; // auto-stretch linked RGB
/*
* Display function transformation.
*/
void Apply( pcl::Image& ) const override;
void Apply( pcl::DImage& ) const override;
void Apply( pcl::UInt8Image& ) const override;
void Apply( pcl::UInt16Image& ) const override;
void Apply( pcl::UInt32Image& ) const override;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_DisplayFunction_h
// ----------------------------------------------------------------------------
// EOF pcl/DisplayFunction.h - Released 2022-03-12T18:59:29Z
-1496
View File
File diff suppressed because it is too large Load Diff
-391
View File
@@ -1,391 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Edit.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Edit_h
#define __PCL_Edit_h
/// \file pcl/Edit.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/AutoPointer.h>
#include <pcl/Frame.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class Edit
* \brief Client-side interface to a PixInsight %Edit control
*
* %Edit controls are single-line plain text edit controls.
*/
class PCL_CLASS Edit : public Frame
{
public:
/*!
* Constructs an %Edit object with the specified \a text, as a child control
* of \a parent.
*/
Edit( const String& text = String(), Control& parent = Control::Null() );
/*!
* Destroys an %Edit control.
*/
virtual ~Edit()
{
}
/*!
* Returns the current edit text.
*/
String Text() const;
/*!
* Sets the current button text.
*/
void SetText( const String& );
/*!
* Removes all the text in this %edit control.
*/
void Clear()
{
SetText( String() );
}
/*!
* Returns true iff this %Edit control is in read-only mode.
*/
bool IsReadOnly() const;
/*!
* Enables or disables the read-only mode for this %Edit control.
*/
void SetReadOnly( bool = true );
/*!
* Disables or enables the read-only mode for this %Edit control.
*
* This is a convenience member function, equivalent to:
* SetReadOnly( !rw )
*/
void SetReadWrite( bool rw = true )
{
SetReadOnly( !rw );
}
/*!
* Returns true iff the text in this %Edit control has been modified.
*/
bool IsModified() const;
/*!
* Sets or clears the modified status for this %Edit control.
*/
void SetModified( bool = true );
/*!
* Clears or sets the modified status for this %Edit control.
*
* This is a convenience member function, equivalent to:
* SetModified( !clear )
*/
void ClearModified( bool clear = true )
{
SetModified( !clear );
}
/*!
* Returns true iff this %Edit control is in <em>password display mode</em>.
*
* In password mode, the text in an edit control is always displayed as a
* sequence of asterisks. This does not affect the actual text; the password
* mode only changes the way characters are displayed.
*
* \sa EnablePasswordMode(), DisablePasswordMode()
*/
bool IsPasswordMode() const;
/*!
* Enables the password display mode for this %Edit control.
*
* \sa IsPasswordMode(), DisablePasswordMode()
*/
void EnablePasswordMode( bool = true );
/*!
* Disables the password display mode for this %Edit control.
*
* This is a convenience member function, equivalent to:
* EnablePasswordMode( !disable )
*
* \sa IsPasswordMode(), EnablePasswordMode()
*/
void DisablePasswordMode( bool disable = true )
{
EnablePasswordMode( !disable );
}
/*!
* Returns the maximum allowed length for the text in this %Edit control.
*/
int MaxLength() const;
/*!
* Sets the maximum allowed length for the text in this %Edit control.
*
* The default length limit is \c int_max, which in practice represents no
* length limit.
*/
void SetMaxLength( int );
/*!
* Enables unlimited length for the text in this %Edit control.
*
* This is a convenience member function, equivalent to:
* SetMaxLength( int_max )
*/
void SetUnlimitedLength()
{
SetMaxLength( int_max );
}
/*!
* Selects all the text in this %edit control.
*/
void SelectAll( bool = true );
/*!
* Clears the existing selection, if any, in this %edit control.
*
* \note This member function does not delete the selected text; it only
* removes the selection.
*/
void Unselect( bool unsel = true )
{
SelectAll( !unsel );
}
/*!
* Gets the limits of the current selection in this %Edit control.
*
* \param[out] selStart The index of the first selected character.
* \param[out] selEnd The index of the last selected character plus one.
*
* When \a selStart is equal to \a selEnd, there is no selection in this
* edit control.
*/
void GetSelection( int& selStart, int& selEnd ) const;
/*!
* Sets the limits of the current selection in this %Edit control.
*
* \param selStart The index of the first selected character.
* \param selEnd The index of the last selected character plus one.
*
* When \a selStart is equal to \a selEnd, there is no selection in this
* edit control.
*/
void SetSelection( int selStart, int selEnd );
/*!
* Returns true iff there are one or more selected characters in this %Edit
* control.
*/
bool HasSelection() const
{
int s0, s1;
GetSelection( s0, s1 );
return s0 != s1;
}
/*!
* Returns the currently selected text, or an empty string if there is no
* selection in this %Edit control.
*/
String SelectedText() const;
/*!
* Returns the current caret position in this %Edit control.
*/
int CaretPosition() const;
/*!
* Sets the current caret position in this %Edit control.
*/
void SetCaretPosition( int );
/*!
* Moves the caret to the beginning of the text line in this %Edit control.
*/
void Home()
{
SetCaretPosition( 0 );
}
/*!
* Moves the caret to the end of the text line in this %Edit control.
*/
void End()
{
SetCaretPosition( int_max );
}
/*!
* Returns true iff the text in this %Edit control is right-aligned.
*/
bool IsRightAligned() const;
/*!
* Returns true iff the text in this %Edit control is left-aligned.
*/
bool IsLeftAligned() const
{
return !IsRightAligned();
}
/*!
* Enables or disables right-alignment for the text in this %edit control.
*/
void SetRightAlignment( bool right = true );
/*!
* Disables or enables right-alignment for the text in this %edit control.
*
* This is a convenience member function, equivalent to:
* SetRightAlignment( !left )
*/
void SetLeftAlignment( bool left = true )
{
SetRightAlignment( !left );
}
// -------------------------------------------------------------------------
// Event handlers
//
// void OnEditCompleted( Edit& sender );
// void OnReturnPressed( Edit& sender );
// void OnTextUpdated( Edit& sender, const String& text );
// void OnCaretPositionUpdated( Edit& sender, int oldPos, int newPos );
// void OnSelectionUpdated( Edit& sender, int newStart, int newEnd );
/*! #
*/
typedef void (Control::*edit_event_handler)( Edit& sender );
/*! #
*/
typedef void (Control::*text_event_handler)( Edit& sender, const String& );
/*! #
*/
typedef void (Control::*caret_event_handler)( Edit& sender, int oldPos, int newPos );
/*! #
*/
typedef void (Control::*selection_event_handler)( Edit& sender, int newStart, int newEnd );
/*! #
*/
void OnEditCompleted( edit_event_handler, Control& );
/*! #
*/
void OnReturnPressed( edit_event_handler, Control& );
/*! #
*/
void OnTextUpdated( text_event_handler, Control& );
/*! #
*/
void OnCaretPositionUpdated( caret_event_handler, Control& );
/*! #
*/
void OnSelectionUpdated( selection_event_handler, Control& );
private:
struct EventHandlers
{
edit_event_handler onEditCompleted = nullptr;
edit_event_handler onReturnPressed = nullptr;
text_event_handler onTextUpdated = nullptr;
caret_event_handler onCaretPositionUpdated = nullptr;
selection_event_handler onSelectionUpdated = nullptr;
EventHandlers() = default;
EventHandlers( const EventHandlers& ) = default;
EventHandlers& operator =( const EventHandlers& ) = default;
};
AutoPointer<EventHandlers> m_handlers;
friend class EditEventDispatcher;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
#endif // __PCL_Edit_h
// ----------------------------------------------------------------------------
// EOF pcl/Edit.h - Released 2022-03-12T18:59:29Z
-401
View File
@@ -1,401 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/ElapsedTime.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_ElapsedTime_h
#define __PCL_ElapsedTime_h
/// \file pcl/ElapsedTime.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/String.h>
#if !defined( __PCL_LINUX ) && !defined( __PCL_FREEBSD )
# include <pcl/Atomic.h>
# include <pcl/AutoLock.h>
# define PCL_CLOCK_ID 0
#endif
#ifdef __PCL_LINUX
# include <time.h>
# ifdef CLOCK_MONOTONIC_RAW // since kernel 2.6.28
# define PCL_CLOCK_ID CLOCK_MONOTONIC_RAW
# else
# define PCL_CLOCK_ID CLOCK_MONOTONIC
# endif
#endif
#ifdef __PCL_FREEBSD
# include <sys/timespec.h>
# ifdef CLOCK_MONOTONIC_PRECISE // since FreeBSD 10.1
# define PCL_CLOCK_ID CLOCK_MONOTONIC_PRECISE
# else
# define PCL_CLOCK_ID CLOCK_MONOTONIC
# endif
#endif
#ifdef __PCL_MACOSX
# include <mach/mach.h>
# include <mach/mach_time.h>
#endif
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class ElapsedTime
* \brief High-resolution time stamp.
*
* %ElapsedTime is a platform-independent, monotonically nondecreasing
* high-resolution time stamp based on hardware time resources that are
* independent on any external time reference. The underlying implementation
* uses monotonic clock services on Linux and FreeBSD (via clock_gettime()
* system calls), performance counters on Windows, and Mach absolute time
* system services on macOS.
*
* Example of use:
*
* \code
* ElapsedTime T;
* for ( int i = 0; i < 100000; ++i )
* foo();
* double t1 = T();
* T.Reset();
* for ( int i = 0; i < 100000; ++i )
* bar();
* double t2 = T();
* Console out;
* out.WriteLn( "Execution times (100K function calls): );
* out.WriteLn( "foo(): " + ElapsedTime::ToString( t1 ) );
* out.WriteLn( "bar(): " + ElapsedTime::ToString( t2 ) );
* \endcode
*
* Timing resolution should be better than one microsecond on all platforms,
* but the actual resolution achieved is hardware and system dependent.
*
* This class is thread-safe: it can be instantiated and its member functions
* can be safely invoked from multiple running threads.
*/
class PCL_CLASS ElapsedTime
{
public:
/*!
* Constructs a new %ElapsedTime object and initializes it with the current
* system time, which will be the starting point of subsequent time interval
* evaluations.
*/
ElapsedTime()
{
Reset();
}
/*!
* Copy constructor.
*/
ElapsedTime( const ElapsedTime& ) = default;
/*!
* Copy assignment operator. Returns a reference to this object.
*/
ElapsedTime& operator =( const ElapsedTime& ) = default;
/*!
* Returns the time interval elapsed since the last object initialization,
* expressed in seconds. An %ElapsedTime object is initialized either when
* it is constructed, or through a subsequent call to the Reset() member
* function.
*/
double operator ()() const
{
return TimeStamp() - m_start;
}
/*!
* Initializes this %ElapsedTime object with a new time stamp, which will be
* the starting point of subsequent time interval evaluations.
*/
void Reset()
{
m_start = TimeStamp();
}
/*!
* Returns an 8-bit string representation of the time interval elapsed since
* the last object initialization. See operator()() and
* ToIsoString( double ) for detailed information.
*/
IsoString ToIsoString() const
{
return ToIsoString( operator()() );
}
/*!
* Returns a Unicode string representation of the time interval elapsed
* since the last object initialization. See operator()() and
* ToIsoString( double ) for detailed information.
*/
String ToString() const
{
return ToString( operator()() );
}
/*!
* IsoString conversion operator. Equivalent to ToIsoString().
*/
operator IsoString() const
{
return ToIsoString();
}
/*!
* String conversion operator. Equivalent to ToString().
*/
operator String() const
{
return ToString();
}
/*!
* Returns a 64-bit, monotonically nondecreasing time stamp.
*
* The returned value is the time elapsed in seconds since an arbitrary,
* platform-dependent starting time that will remain invariant during the
* current execution of the calling module.
*
* With the current implementation, accuracy of timestamps should be better
* than one microsecond on all supported platforms.
*/
static double TimeStamp()
{
#if defined( __PCL_LINUX ) || defined( __PCL_FREEBSD )
/*
* Linux/FreeBSD implementation based on clock_gettime().
*/
timespec ts;
(void)clock_gettime( PCL_CLOCK_ID, &ts );
return ts.tv_sec + ts.tv_nsec*1.0e-09;
#endif // __PCL_LINUX || __PCL_FREEBSD
#ifdef __PCL_MACOSX
/*
* macOS implementation based on Mach absolute time system services.
*
* https://developer.apple.com/library/mac/qa/qa1398/_index.html
* http://stackoverflow.com/questions/5167269/clock-gettime-alternative-in-mac-os-x
*/
static Mutex mutex;
static AtomicInt initialized;
static double absoluteToSeconds;
static uint64 offset;
if ( !initialized )
{
volatile AutoLock lock( mutex );
if ( initialized.Load() == 0 )
{
mach_timebase_info_data_t timeBase = { 0 };
mach_timebase_info( &timeBase );
absoluteToSeconds = 1.0e-09*(double( timeBase.numer )/timeBase.denom);
offset = mach_absolute_time();
initialized.Store( 1 );
}
}
uint64 t = mach_absolute_time();
return (t - offset)*absoluteToSeconds;
#endif // __PCL_MACOSX
#ifdef __PCL_WINDOWS
/*
* Windows implementation based on Win32 performance counters.
*
* https://msdn.microsoft.com/en-us/library/windows/desktop/ms644905%28v=vs.85%29.aspx
* https://msdn.microsoft.com/en-us/library/windows/desktop/ms644904%28v=vs.85%29.aspx
* http://stackoverflow.com/questions/5404277/porting-clock-gettime-to-windows
* http://stackoverflow.com/questions/1676036/what-should-i-use-to-replace-gettimeofday-on-windows
*/
static Mutex mutex;
static AtomicInt initialized;
static double countsToSeconds;
static uint64 offset;
if ( !initialized )
{
volatile AutoLock lock( mutex );
if ( initialized.Load() == 0 )
{
uint64 performanceFrequency;
QueryPerformanceFrequency( (LARGE_INTEGER*)&performanceFrequency );
countsToSeconds = 1.0/performanceFrequency;
QueryPerformanceCounter( (LARGE_INTEGER*)&offset );
initialized.Store( 1 );
}
}
uint64 t;
QueryPerformanceCounter( (LARGE_INTEGER*)&t );
return (t - offset)*countsToSeconds;
#endif // __PCL_WINDOWS
}
/*!
* Returns an 8-bit string representation of the specified time interval
* in seconds.
*
* The returned string has one of the following formats:
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>(1) u.uuu us</td> <td>u.uuu is the time t in microseconds if t < 0.001 s</td></tr>
* <tr><td>(2) m.mmm ms</td> <td>m.mmm is the time t in milliseconds if t < 1.0 s</td></tr>
* <tr><td>(3) s.sss s</td> <td>s.sss is the time t in seconds if t < 60.0 s</td></tr>
* <tr><td>(4) mm:ss.ss</td> <td>Zero-padded minutes and seconds if t < 3600 s</td></tr>
* <tr><td>(5) hh:mm:ss.s</td> <td>Same as (4) with zero-padded hours if t < 86400 s</td></tr>
* <tr><td>(6) d:hh:mm:ss</td> <td>Same as (5) with elapsed days if t >= 86400</td></tr>
* </table>
*
* If \a width > 0 and t &le; 60, the integer part of the represented
* microseconds, milliseconds or seconds will be right-padded in a field of
* \a width space characters.
*
* The output format is chosen automatically to generate the most
* significant representation. If the specified interval is negative (toward
* the past), a minus sign is prepended to the returned string.
*/
static IsoString ToIsoString( double seconds, int width = 0 )
{
return ToString( seconds, width, (IsoString*)0 );
}
/*!
* Returns a Unicode string representation of the specified time interval
* \a s in seconds. See ToIsoString( double ) for information on the
* representation format.
*/
static String ToString( double s, int width = 0 )
{
return ToString( s, width, (String*)0 );
}
/*!
* Returns the time interval in seconds elapsed between the starting points
* of two %ElapsedTime objects \a t1 and \a t2. The result is positive if
* \a t2 precedes \a t1, negative if \a t1 precedes \a t2, zero if and only
* if either \a t1 and \a t2 are references to the same instance, or if one
* of the objects has been constructed as a copy of the other.
*/
friend double operator -( const ElapsedTime& t1, const ElapsedTime& t2 )
{
return t1.m_start - t2.m_start;
}
private:
double m_start; // timestamp in seconds
template <class S>
static S ToString( double s, int w, S* )
{
if ( s < 0.001 )
return S().Format( "%*.3f us", Max( 5, w+4 ), s*1000000 );
if ( s < 1 )
return S().Format( "%*.3f ms", Max( 5, w+4 ), s*1000 );
if ( s < 60 )
return S().Format( "%*.3f s", Max( 5, w+4 ), s );
int sign = (s < 0) ? -1 : +1;
s = Abs( s );
if ( s < 3600 )
{
int m = TruncInt( s/60 );
s -= m*60;
return S().Format( "%02d:%05.2f", m*sign, s );
}
if ( s < 86400 )
{
int h = TruncInt( s/3600 );
s -= h*3600;
int m = TruncInt( s/60 );
s -= m*60;
return S().Format( "%02d:%02d:%04.1f", h*sign, m, s );
}
int d = TruncInt( s/86400 );
s -= d*86400;
int h = TruncInt( s/3600 );
s -= h*3600;
int m = TruncInt( s/60 );
s -= m*60;
return S().Format( "%d:%02d:%02d:%02d", d*sign, h, m, RoundInt( s ) );
}
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_ElapsedTime_h
// ----------------------------------------------------------------------------
// EOF pcl/ElapsedTime.h - Released 2022-03-12T18:59:29Z
-168
View File
@@ -1,168 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/EndianConversions.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_EndianConversions_h
#define __PCL_EndianConversions_h
/// \file pcl/EndianConversions.h
#include <pcl/Defs.h>
#include <pcl/Math.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \defgroup endianness_conversion_and_detection Endianness Conversion and Detection Functions
*/
/*!
* Converts a 16-bit unsigned integer from big endian to little endian byte
* storage order.
*
* \ingroup endianness_conversion_and_detection
*/
inline uint16 BigToLittleEndian( uint16 x )
{
return (x << 8) | (x >> 8);
}
/*!
* Converts a 32-bit unsigned integer from big endian to little endian byte
* storage order.
*
* \ingroup endianness_conversion_and_detection
*/
inline uint32 BigToLittleEndian( uint32 x )
{
return (RotL( x, 8 ) & 0x00ff00ffu) | (RotR( x, 8 ) & 0xff00ff00u);
}
/*!
* Converts a 64-bit unsigned integer from big endian to little endian byte
* storage order.
*
* \ingroup endianness_conversion_and_detection
*/
inline uint64 BigToLittleEndian( uint64 x )
{
return (uint64( BigToLittleEndian( uint32( x ) ) ) << 32) | uint64( BigToLittleEndian( uint32( x >> 32 ) ) );
}
/*!
* A convenience synonym function for little-to-big endian conversions, which
* we define for the sake of code legibility. It is obviously equivalent to
* BigToLittleEndian( x ).
*
* \ingroup endianness_conversion_and_detection
*/
template <typename T> inline T LittleToBigEndian( T x )
{
return BigToLittleEndian( x );
}
// ----------------------------------------------------------------------------
union __pcl_endian_check__ { uint32 w; uint8 b[ sizeof( uint32 ) ]; };
constexpr __pcl_endian_check__ __pcl_endian_check_sample__ = { 0xdeadbeef };
#ifdef __clang__
inline bool IsLittleEndianMachine()
{
return __pcl_endian_check_sample__.b[0] == 0xef;
}
inline bool IsBigEndianMachine()
{
return __pcl_endian_check_sample__.b[0] == 0xde;
}
#else
// Clang fails here with "read of member 'b' of union with active member 'w' is
// not allowed in a constant expression".
/*!
* Returns true iff the caller is running on a little-endian architecture.
*
* \ingroup endianness_conversion_and_detection
*/
constexpr bool IsLittleEndianMachine()
{
return __pcl_endian_check_sample__.b[0] == 0xef;
}
/*!
* Returns true iff the caller is running on a big-endian architecture.
*
* \ingroup endianness_conversion_and_detection
*/
constexpr bool IsBigEndianMachine()
{
return __pcl_endian_check_sample__.b[0] == 0xde;
}
#endif // __clang__
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_EndianConversions_h
// ----------------------------------------------------------------------------
// EOF pcl/EndianConversions.h - Released 2022-03-12T18:59:29Z
File diff suppressed because it is too large Load Diff
-184
View File
@@ -1,184 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/ErrorHandler.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_ErrorHandler_h
#define __PCL_ErrorHandler_h
/// \file pcl/ErrorHandler.h
#include <pcl/Defs.h>
#include <pcl/Exception.h>
#include <new> // std::bad_alloc
// ----------------------------------------------------------------------------
#ifdef __PCL_SILENTLY_REPLACE_USER_ERROR_MACROS
#undef ERROR_HANDLER
#undef ERROR_CLEANUP
#else
#ifdef ERROR_HANDLER
#error ERROR_HANDLER macro: Already defined!
#endif
#ifdef ERROR_CLEANUP
#error ERROR_CLEANUP macro: Already defined!
#endif
#endif
// ----------------------------------------------------------------------------
/*!
* \defgroup error_handling_macros Error Handling Macros
*/
// ----------------------------------------------------------------------------
/*!
* \def ERROR_HANDLER
* \brief Standard PCL error handler macro
*
* Use the ERROR_HANDLER macro after try blocks in all PCL programs and
* modules.
*
* \ingroup error_handling_macros
*/
#define ERROR_HANDLER \
catch ( pcl::FatalError& ) \
{ \
/* Launch fatal errors to the hyperspace... */ \
throw; \
} \
catch ( pcl::ProcessAborted& ) \
{ \
/* Abort process: Let the PI application do the GUI output */ \
} \
catch ( pcl::CaughtException& ) \
{ \
/* Exceptions already caught and managed: simply ignore them */ \
} \
catch ( pcl::Exception& x ) \
{ \
/* Other PCL exceptions */ \
x.Show(); \
} \
catch ( pcl::String& s ) \
{ \
/* Nonstandard ways of throwing things... */ \
try \
{ \
throw pcl::Error( s ); \
} \
catch ( pcl::Exception& x ) \
{ \
x.Show(); \
} \
} \
catch ( std::bad_alloc& ) \
{ \
/* Standard bad allocation exception */ \
try \
{ \
throw pcl::Error( "Out of memory" ); \
} \
catch ( pcl::Exception& x ) \
{ \
x.Show(); \
} \
} \
catch ( ... ) \
{ \
/* Catch-all */ \
try \
{ \
throw pcl::Error( "Unknown exception" ); \
} \
catch ( pcl::Exception& x ) \
{ \
x.Show(); \
} \
}
// ----------------------------------------------------------------------------
/*!
* \def ERROR_CLEANUP
* \brief Standard PCL error handler macro with cleanup code
*
* Use ERROR_CLEANUP in the same way as the ERROR_HANDLER macro, when you need
* to specify a local clean up code, e.g. to delete dynamically allocated local
* variables.
*
* \ingroup error_handling_macros
*/
#define ERROR_CLEANUP( cleanup_code ) \
catch ( ... ) \
{ \
cleanup_code; \
\
try \
{ \
throw; \
} \
ERROR_HANDLER \
}
// ----------------------------------------------------------------------------
#endif // __PCL_ErrorHandler_h
// ----------------------------------------------------------------------------
// EOF pcl/ErrorHandler.h - Released 2022-03-12T18:59:29Z
-671
View File
@@ -1,671 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Exception.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Exception_h
#define __PCL_Exception_h
/// \file pcl/Exception.h
#include <pcl/Defs.h>
#include <pcl/String.h>
#include <typeinfo>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \defgroup standard_exception_classes Standard Exception Classes
*/
/*!
* \class Exception
* \brief Root base class for all PCL exception classes
*
* All exceptions thrown by PCL classes and functions are descendants of the
* %Exception class.
*
* \ingroup standard_exception_classes
*/
class PCL_CLASS Exception
{
public:
/*!
* Constructs an %Exception object.
*/
Exception() = default;
/*!
* Copy constructor.
*/
Exception( const pcl::Exception& ) = default;
/*!
* Destroys an %Exception object.
*/
virtual ~Exception()
{
}
/*!
* Returns an error class for this exception.
*/
virtual String ExceptionClass() const
{
return String();
}
/*!
* Returns an error or warning message corresponding to this exception.
*/
virtual String Message() const
{
return String();
}
/*!
* Returns a formatted representation of the information transported by this
* %Exception object.
*/
virtual String FormatInfo() const;
/*!
* Returns a caption text suitable to represent the information in this
* %Exception object.
*/
virtual String Caption() const;
/*!
* Shows a representation of the information transported by this exception.
*
* Exception information can be shown as text on the platform console or
* using graphical interfaces, depending on a global setting controlled with
* the EnableConsoleOutput() and EnableGUIOutput() static member functions.
*
* \sa IsConsoleOutputEnabled(), IsGUIOutputEnabled()
*/
virtual void Show() const;
/*!
* Prints a representation of the information transported by this exception
* exclusively as plain text on the platform console.
*
* This function ignores current settings defined through previous calls to
* EnableConsoleOutput() and EnableGUIOutput().
*/
PCL_FORCE_INLINE void ShowOnConsole() const
{
/*
* N.B.: This function must always be expanded inline. Otherwise, neither
* UNIX synchronous signal handlers nor Win32 structured exception
* handlers can throw C++ exceptions.
*/
bool wasConsoleOutput = IsConsoleOutputEnabled();
bool wasGUIOutput = IsGUIOutputEnabled();
EnableConsoleOutput();
DisableGUIOutput();
Exception::Show();
EnableConsoleOutput( wasConsoleOutput );
EnableGUIOutput( wasGUIOutput );
}
/*!
* Returns true iff console text output is enabled for %Exception.
*
* When console output is enabled, exception information is presented as
* text on the PixInsight core application's console. Console exception
* output is always enabled by default.
*
* \sa IsGUIOutputEnabled(), EnableConsoleOutput(), EnableGUIOutput()
*/
static bool IsConsoleOutputEnabled();
/*!
* Enables console output for %Exception.
*
* \sa IsConsoleOutputEnabled(), DisableConsoleOutput(),
* IsGUIOutputEnabled(), EnableGUIOutput()
*/
static void EnableConsoleOutput( bool = true );
/*!
* Disables console output for %Exception.
*
* \sa IsConsoleOutputEnabled(), EnableConsoleOutput(),
* IsGUIOutputEnabled(), EnableGUIOutput()
*/
static void DisableConsoleOutput( bool disable = true )
{
EnableConsoleOutput( !disable );
}
/*!
* Returns true iff GUI output is enabled for %Exception.
*
* When GUI output is enabled, exception information is presented through
* message boxes and other modal, graphical interface elements. GUI
* exception output is always disabled by default.
*
* \sa IsConsoleOutputEnabled(), EnableConsoleOutput(), EnableGUIOutput()
*/
static bool IsGUIOutputEnabled();
/*!
* Enables GUI output for %Exception.
*
* \sa IsGUIOutputEnabled(), DisableGUIOutput(), IsConsoleOutputEnabled(),
* EnableConsoleOutput()
*/
static void EnableGUIOutput( bool = true );
/*!
* Disables GUI output for %Exception.
*
* \sa IsGUIOutputEnabled(), EnableGUIOutput(), IsConsoleOutputEnabled(),
* EnableConsoleOutput()
*/
static void DisableGUIOutput( bool disable = true )
{
EnableGUIOutput( !disable );
}
};
// ----------------------------------------------------------------------------
/*!
* \class Error
* \brief A simple exception with an associated error message.
*
* %Error is a general exception message very frequently used by PCL classes
* and functions.
*
* \ingroup standard_exception_classes
*/
class PCL_CLASS Error : public pcl::Exception
{
public:
/*!
* Constructs an %Error object with an empty error message.
*/
Error() = default;
/*!
* Copy constructor.
*/
Error( const Error& ) = default;
/*!
* Constructs an %Error object with the specified error \a message.
*/
Error( const String& message )
: m_message( message )
{
}
/*!
* Returns descriptive information for this %Error object. The default
* implementation returns the message specified upon construction. A derived
* class can reimplement this function to provide additional information
* items such as file names, object identifiers, source code positions, date
* and time representations, etc.
*/
String Message() const override
{
return m_message;
}
/*!
*/
String Caption() const override
{
return "Error";
}
protected:
String m_message;
};
// ----------------------------------------------------------------------------
/*!
* \class FatalError
* \brief Errors that cause immediate program termination
*
* %FatalError indicates an error situation that cannot be resumed and requires
* immediate program termination.
*
* \ingroup standard_exception_classes
*/
class PCL_CLASS FatalError : public Error
{
public:
/*!
* Constructs a %FatalError object with an empty message.
*/
FatalError() = default;
/*!
* Constructs a %FatalError object with the specified \a message.
*/
FatalError( const String& message )
: Error( message )
{
}
/*!
* "Promote" any exception to have "fatal consequences".
*/
FatalError( const pcl::Exception& x )
: Error( x.Message() )
{
}
/*!
* Copy constructor.
*/
FatalError( const pcl::FatalError& ) = default;
/*!
*/
String Caption() const override
{
return "Fatal Error";
}
};
// ----------------------------------------------------------------------------
/*!
* \class NotImplemented
* \brief An exception that indicates an unsupported feature
*
* Throw one of these when you have an object that can't do something.
*
* \ingroup standard_exception_classes
*/
class PCL_CLASS NotImplemented : public Error
{
public:
/*!
* Constructs a %NotImplemented instance.
*
* \param object The object that does not implement something
*
* \param notImplemented A description of what \a object does not
* implement.
*/
template <typename T>
NotImplemented( const T& object, const String& notImplemented )
: Error( String( IsoString( typeid( object ).name() )
#ifdef __PCL_WINDOWS
.MBSToWCS()
#else
.UTF8ToUTF16()
#endif
) + ": Not implemented: " + notImplemented )
{
}
/*!
* Copy constructor.
*/
NotImplemented( const NotImplemented& ) = default;
};
// ----------------------------------------------------------------------------
/*!
* \class ParseError
* \brief Base class for exceptions thrown by parsing routines
*
* A %ParseError indicates an syntactic or semantic error found while
* interpreting some code or trying to translate some text into an object.
*
* For example, String and IsoString throw %ParseError exceptions to indicate
* syntax errors while converting strings to numbers.
*
* \ingroup standard_exception_classes
*/
class PCL_CLASS ParseError : public Error
{
public:
/*!
* Constructs an empty %ParseError object: no error message and no position
* information.
*/
ParseError() = default;
/*!
* Copy constructor.
*/
ParseError( const ParseError& ) = default;
/*!
* Constructs a %ParseError object.
*
* \param message The error message. HTML entities are not interpreted as
* ISO 8859-1 characters, and console tags are ignored, even if
* the exception is to be represented on a PixInsight console.
* HTML entities and console tags are always written literally.
* This limitation is necessary to ensure representativeness of
* source code fragments shown in exception messages.
*
* \param beingParsed The string being parsed, or an empty string if the
* error is not associated to a particular source code string.
*
* \param errorPosition The position >= 0 of the first offending character
* in the string \a beingParsed, or < 0 if no specific position
* can be associated with the error.
*/
ParseError( const String& message, const String& beingParsed = String(), int errorPosition = -1 )
: Error( message )
, m_beingParsed( beingParsed )
, m_errorPosition( errorPosition )
{
}
/*!
*/
String Message() const override;
/*!
*/
void Show() const override;
protected:
String m_beingParsed;
int m_errorPosition = -1;
};
// ----------------------------------------------------------------------------
/*!
* \class SourceCodeError
* \brief Base class for exceptions thrown by source code interpreters
*
* A %SourceCodeError represents a syntax error thrown by a source code parser
* or interpreter, such as a scripting engine or an XML decoder.
*
* %SourceCodeError provides an error message string associated to a line
* number and a column number that locate the error in the source code text
* being processed.
*
* \ingroup standard_exception_classes
*/
class PCL_CLASS SourceCodeError : public Error
{
public:
/*!
* Constructs an empty %SourceCodeError object: no error message and no
* source code location information.
*/
SourceCodeError() = default;
/*!
* Copy constructor.
*/
SourceCodeError( const SourceCodeError& ) = default;
/*!
* Constructs a %SourceCodeError object.
*
* \param message The error message. HTML entities are not interpreted as
* ISO 8859-1 characters, and console tags are ignored, even if
* the exception is to be represented on a PixInsight console.
* HTML entities and console tags are always written literally.
* This limitation is necessary to ensure representativeness of
* source code fragments in exception messages.
*
* \param line The line number (starting from 1) corresponding to the
* position of this error in the source code text, or <= 0 if no
* specific source code line can be associated with this error.
* The default value is -1, meaning that no line number is
* specified by default.
*
* \param column The column number (starting from 1) corresponding to
* the position of this error in the source code text, or <= 0
* if no specific source code column can be associated with this
* error. The default value is -1, meaning that no column number
* is specified by default.
*/
template <typename T1>
SourceCodeError( const String& message, T1 line = -1, T1 column = -1 )
: Error( message )
, m_lineNumber( Range( int( line ), -1, int_max ) )
, m_columnNumber( Range( int( column ), -1, int_max ) )
{
}
/*!
* Returns the line number in the source code text being processed,
* corresponding to this exception.
*
* If a valid source code line can be associated with this exception, the
* returned value should be >= 1. Otherwise, if no text line can be
* determined for this exception, -1 is returned.
*
* \sa ColumnNumber()
*/
int LineNumber() const
{
return m_lineNumber;
}
/*!
* Returns the column number in the source code text being processed,
* corresponding to this exception.
*
* If a valid source code column can be associated with this exception, the
* returned value should be >= 1. Otherwise, if no text column can be
* determined for this exception, -1 is returned.
*
* \sa LineNumber()
*/
int ColumnNumber() const
{
return m_columnNumber;
}
/*!
* Sets the source code \a line number and \a column (optional) for this
* exception.
*
* Valid (meaningful) source code coordinates must be >= 1. When a value < 0
* is specified, the corresponding coordinate is interpreted to be
* unavailable for the current exception.
*
* This member function is useful when nested sections of a source code
* block are being processed recursively; for example in XML decoders.
*
* \sa AddToPosition()
*/
template <typename T1>
void SetPosition( T1 line, T1 column = -1 )
{
m_lineNumber = Range( int( line ), -1, int_max );
m_columnNumber = Range( int( column ), -1, int_max );
}
/*!
* Adds the specified \a lines and \a columns (optional) increments to the
* source code coordinates for this exception.
*
* Valid (meaningful) source code coordinates must be >= 1. When a value
* <= 0 results from a call to this function, the corresponding coordinate
* is interpreted to be unavailable for the current exception.
*
* This member function is useful when nested sections of a source code
* block are being processed recursively; for example in XML decoders.
*
* \sa SetPosition()
*/
template <typename T1>
void AddToPosition( T1 lines, T1 columns = 0 )
{
SetPosition( m_lineNumber+int( lines ), m_columnNumber+int( columns ) );
}
/*!
*/
String Message() const override;
/*!
*/
void Show() const override;
protected:
int m_lineNumber = -1;
int m_columnNumber = -1;
};
// ----------------------------------------------------------------------------
/*!
* \class CaughtException
* \brief An exception that has already been handled
*
* %CaughtException is used to signal exceptions requiring no additional
* processing. %CaughtException is useful to terminate a process (by branching
* execution to a catch() block) without causing generation of further error
* messages.
*
* \ingroup standard_exception_classes
*/
class PCL_CLASS CaughtException : public pcl::Exception
{
public:
/*!
* Constructs a %CaughtException object.
*/
CaughtException() = default;
/*!
* Copy constructor.
*/
CaughtException( const pcl::CaughtException& ) = default;
};
} // pcl
// ----------------------------------------------------------------------------
/*!
* \def PCL_DECLARE_EXCEPTION_CLASS
* \brief A macro to implement simple exception classes derived from Exception
*
* \param className The identifier of the exception class.
*
* \param exceptionClass The name of the exception class, as presented in
* formatted representations.
*
* \param message The error message shown for this exception class.
*
* Use this macro to define and implement exceptions classes that show
* constant error or warning messages.
*
* In many cases using the %Error exception class is preferable to create new
* exception classes with this macro.
*
* \ingroup standard_exception_classes
*/
#define PCL_DECLARE_EXCEPTION_CLASS( className, exceptionClass, message ) \
class PCL_CLASS className : public pcl::Exception \
{ \
public: \
className() = default; \
className( const className& ) = default; \
pcl::String ExceptionClass() const override \
{ \
return exceptionClass; \
} \
pcl::String Message() const override \
{ \
return message; \
} \
}
// ----------------------------------------------------------------------------
namespace pcl
{
/*!
* \class pcl::ProcessAborted
* \brief An exception class signaling the interruption of a process
*
* %ProcessAborted is thrown by processes that have been aborted by the user.
*
* \ingroup standard_exception_classes
*/
PCL_DECLARE_EXCEPTION_CLASS( ProcessAborted, "Process aborted", String() );
} // pcl
#endif // __PCL_Exception_h
// ----------------------------------------------------------------------------
// EOF pcl/Exception.h - Released 2022-03-12T18:59:29Z
-852
View File
@@ -1,852 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/ExternalProcess.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_ExternalProcess_h
#define __PCL_ExternalProcess_h
/// \file pcl/ExternalProcess.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/AutoPointer.h>
#include <pcl/Control.h>
#include <pcl/Flags.h>
#include <pcl/UIObject.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::ExternalProcessError
* \brief External process error conditions.
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>ExternalProcessError::FailedToStart</td> <td>The external process failed to start.</td></tr>
* <tr><td>ExternalProcessError::Crashed</td> <td>The external process crashed.</td></tr>
* <tr><td>ExternalProcessError::TimedOut</td> <td>A wait operation timed out.</td></tr>
* <tr><td>ExternalProcessError::ReadError</td> <td>An error occurred while trying to read data from a process' stdout or stderr streams.</td></tr>
* <tr><td>ExternalProcessError::WriteError</td> <td>An error occurred while trying to write data to a process' stdin stream.</td></tr>
* <tr><td>ExternalProcessError::UnknownError</td> <td>An unknown error occurred trying to execute or communicate with an external process.</td></tr>
* </table>
*/
namespace ExternalProcessError
{
enum value_type
{
FailedToStart,
Crashed,
TimedOut,
ReadError,
WriteError,
UnknownError
};
}
// ----------------------------------------------------------------------------
/*!
* \class ExternalProcess
* \brief Execution of external programs.
*
* %ExternalProcess is essentially a PCL wrapper to Qt's QProcess class, which
* the PixInsight core application uses as the underlying implementation for
* management of external processes on the PixInsight platform.
*
* ### TODO: Write a detailed description for %ExternalProcess.
*/
class PCL_CLASS ExternalProcess : public UIObject
{
public:
#ifndef __PCL_WINDOWS
/*!
* The type of a platform-dependent Process Identifier (PID).
*
* On Linux/UNIX (Linux, FreeBSD and Mac OS X), a PID is a 64-bit integer.
*
* On Windows platforms, a PID is a pointer to a _PROCESS_INFORMATION
* structure (hence, on 64-bit Windows platforms a PID is also a 64-bit
* integer number).
*/
typedef int64 pid_type;
#else
typedef void* pid_type;
#endif
/*!
* The type used to represent error conditions in external processes.
*/
typedef ExternalProcessError::value_type error_code;
/*!
* Constructs an %ExternalProcess object.
*/
ExternalProcess();
/*!
* Destroys the client-side %ExternalProcess instance and dereferences the
* server-side object. If the server-side object becomes unreferenced, it
* will be garbage-collected and eventually destroyed by the core
* application.
*/
virtual ~ExternalProcess()
{
}
/*!
* Copy constructor. Copy semantics are disabled for %ExternalProcess
* because this class represents unique server-side objects.
*/
ExternalProcess( const ExternalProcess& ) = delete;
/*!
* Copy assignment. Copy semantics are disabled for %ExternalProcess because
* this class represents unique server-side objects.
*/
ExternalProcess& operator =( const ExternalProcess& ) = delete;
/*!
* Move constructor. Move semantics are disabled for %ExternalProcess
* because of parent-child server-side object relations.
*/
ExternalProcess( ExternalProcess&& ) = delete;
/*!
* Move assignment. Move semantics are disabled for %ExternalProcess because
* of parent-child server-side object relations.
*/
ExternalProcess& operator =( ExternalProcess&& ) = delete;
/*!
* Ensures that the server-side object managed by this instance is uniquely
* referenced.
*
* Since external processes are unique objects, calling this member function
* has no effect.
*/
void EnsureUnique() override
{
}
/*!
* Returns a reference to a null %ExternalProcess instance. A null
* %ExternalProcess does not correspond to an existing external process in
* the PixInsight core application.
*/
static ExternalProcess& Null();
/*!
* Attempts to execute an external process.
*
* \param program Path to the executable file.
*
* \param arguments Optional list of command-line arguments that will be
* passed to the executable. Arguments containing spaces
* will be enclosed by quotes automatically. The default
* value is an empty list.
*
* If the specified \a program cannot be executed for some reason (for
* example, because the specified \a program does not exist, or because the
* calling process doesn't have enough privileges), this function throws an
* Error exception.
*
* This function implicitly opens the standard input, output and error I/O
* streams (stdin, stdout and stderr, respectively) of the running process.
* You can read from and write to the process using the Read() and Write()
* member functions of %ExternalProcess, respectively. You can also close
* the I/O streams using the CloseXX() member functions.
*/
void Start( const String& program, const StringList& arguments = StringList() );
/*!
* Waits for the process to start execution.
*
* \param ms Maximum waiting time in milliseconds. If a negative
* value is specified, this function will never time out.
* The default waiting time is 6000 ms (six seconds).
*
* This function suspends the calling task for at most the specified time,
* or forever if a negative time value is specified. Returns true if the
* process started before the specified time elapsed. Returns false if the
* process timed out. In the latter case, this function can be called again
* to continue waiting for the process to start.
*
* \warning When called from the root thread, this function can freeze the
* entire PixInsight graphical interface. For asynchronous external process
* execution, consider calling WaitForXX() functions from a separate thread.
* Be aware that if you specify a large waiting time or a negative value,
* this function may crash the calling thread.
*/
bool WaitForStarted( int ms = 6000 );
/*!
* Waits for the running process to finish execution.
*
* \param ms Maximum waiting time in milliseconds. If a negative
* value is specified, this function will never time out.
* The default waiting time is 6000 ms (six seconds).
*
* This function suspends the calling task for at most the specified time,
* or forever if a negative time value is specified. Returns true if the
* process finished its execution before the specified time elapsed. Returns
* false if the process timed out. In the latter case, this function can be
* called again to continue waiting for the process to finish.
*
* \warning When called from the root thread, this function can freeze the
* entire PixInsight graphical interface. For asynchronous external process
* execution, consider calling WaitForXX() functions from a separate thread.
* Be aware that if you specify a large waiting time or a negative value,
* this function may crash the calling thread.
*/
bool WaitForFinished( int ms = 6000 );
/*!
* Waits for the running process to send data.
*
* \param ms Maximum waiting time in milliseconds. If a negative
* value is specified, this function will never time out.
* The default waiting time is 6000 ms (six seconds).
*
* This function suspends the calling task for at most the specified time,
* or forever if a negative time value is specified. Returns true if the
* process sent some data through one of its output streams (standard output
* or standard error) before the specified time elapsed. Returns false if
* the process timed out. In the latter case, this function can be called
* again to continue waiting for the process to generate output data. When
* new output data is available from the process, it can be read immediately
* by calling one of the Read() member functions.
*
* \warning When called from the root thread, this function can freeze the
* entire PixInsight graphical interface. For asynchronous external process
* execution, consider calling WaitForXX() functions from a separate thread.
* Be aware that if you specify a large waiting time or a negative value,
* this function may crash the calling thread.
*/
bool WaitForDataAvailable( int ms = 6000 );
/*!
* Waits for the running process to receive data.
*
* \param ms Maximum waiting time in milliseconds. If a negative
* value is specified, this function will never time out.
* The default waiting time is 6000 ms (six seconds).
*
* This function suspends the calling task for at most the specified time,
* or forever if a negative time value is specified. Returns true if the
* process received the data sent previously through its input stream (the
* process' <em>standard input</em>) before the specified time elapsed.
* Returns false if the process timed out. In the latter case, this function
* can be called again to continue waiting for the process to fetch its
* input data. Data can be sent to a running process by calling one of the
* Write() member functions.
*
* \warning When called from the root thread, this function can freeze the
* entire PixInsight graphical interface. For asynchronous external process
* execution, consider calling WaitForXX() functions from a separate thread.
* Be aware that if you specify a large waiting time or a negative value,
* this function may crash the calling thread.
*/
bool WaitForDataWritten( int ms = 6000 );
/*!
* Attempts to terminate the running process.
*
* On Linux/UNIX platforms (Linux, FreeBSD and Mac OS X) a SIGTERM signal is
* sent to the process.
*
* On Windows, this function sends WM_CLOSE messages to all top-level
* windows owned by the process and to its main thread. Console Windows
* applications that don't have a message loop, or GUI Windows applications
* that don't process WM_CLOSE messages adequately, cannot be terminated by
* calling this member function. In these cases, the only way to terminate
* the running process is by calling Kill().
*
* \note Note that there is no guarantee that the running process will
* terminate after calling this function.
*/
void Terminate();
/*!
* Forces termination of the running process.
*
* On Linux/UNIX platforms (Linux, FreeBSD and Mac OS X) a SIGKILL signal is
* sent to the process.
*
* On Windows, the TerminateProcess() API function is called to force
* process termination.
*
* \warning Unconditional termination of processes is always risky and
* should be avoided. For example, the running program wil not have an
* opportunity to close open files or save modified data. This function
* should only be used as a last resort to terminate a process.
*/
void Kill();
/*!
* Closes the standard input stream (stdin) of the running process.
*
* After calling this function, you no longer can write to the process using
* one of the Write() member functions (doing so will always throw an Error
* exception due to an I/O error).
*
* There are programs that require you to close the input stream explicitly.
* An example is the 'cat' UNIX utility. For example, if you enter the 'cat'
* command from a UNIX terminal, the program starts reading data from its
* stdin stream (which is the terminal in this example) until you press the
* "Ctrl+D" combination to close it.
*
* \note This function can only be called for a running process. If the
* process is not running, an Error exception is thrown.
*/
void CloseStandardInput();
/*!
* Closes the standard output stream (stdout) of the running process.
*
* After calling this function, you no longer can read data from the process
* through its stdin stream. Calling this function can be useful to save
* memory for processes that generate large amounts of output data, or if a
* running process starts producing loads of data that you don't want to
* process anymore.
*
* \note This function can only be called for a running process. If the
* process is not running, an Error exception is thrown.
*/
void CloseStandardOutput();
/*!
* Closes the standard error stream (stderr) of the running process.
*
* After calling this function, you no longer can read data from the process
* through its stderr stream. Calling this function can be useful to save
* memory for processes that generate large amounts of output data, or if a
* running process starts producing loads of data that you don't want to
* process anymore.
*
* \note This function can only be called for a running process. If the
* process is not running, an Error exception is thrown.
*/
void CloseStandardError();
/*!
* Redirects the standard output stream (stdout) of the process to the
* specified file.
*
* \param filePath Path to the file where the process will write its
* standard output data.
*
* \param append If true and the specified file already exists, its
* contents will be preserved and newly generated data
* will be appended. If false, the existing file will be
* overwritten and its previous contents will be lost. The
* default value is false (overwrite).
*
* Example:
*
* \code
* ExternalProcess p1, p2;
* p1.RedirectStandardOutput( "/tmp/foo.txt" );
* p1.Start( "ls", StringList() << "-la" << "*.bar" );
* \endcode
*
* The above code snippet is equivalent to this command:
*
* <tt>ls -la *.bar >/tmp/foo.txt</tt>
*
* \note This member function can only be called before running the process,
* i.e. before calling Start(). Otherwise an Error exception is thrown.
*/
void RedirectStandardOutput( const String& filePath, bool append = false );
/*!
* Redirects the standard output stream (stdout) of the process to the
* specified process.
*
* \param process Reference to a process where this process will write
* its standard output data.
*
* This function can be used to build a \e pipe between two programs. For
* example:
*
* \code
* ExternalProcess p1, p2;
* p1.RedirectStandardOutput( p2 );
* p1.Start( "cat", StringList() << "*.bar" );
* p2.Start( "grep", StringList() << "\'foo\'" );
* \endcode
*
* would produce the same result as this command:
*
* <tt>cat *.bar |grep 'foo'</tt>
*
* \note This member function can only be called before running both
* processes, i.e. before calling Start() for this process \e and the
* specified \a process. Otherwise an Error exception is thrown.
*/
void RedirectStandardOutput( ExternalProcess& process );
/*!
* Redirects the standard error output stream (stderr) of the process to the
* specified file.
*
* \param filePath Path to the file where the process will write its
* standard error data.
*
* \param append If true and the specified file already exists, its
* contents will be preserved and newly generated data
* will be appended. If false, the existing file will be
* overwritten and its previous contents will be lost. The
* default value is false (overwrite).
*
* For more information on redirection of process output, see the
* RedirectStandardOutput() functions.
*/
void RedirectStandardError( const String& filePath, bool append = false );
/*!
* Redirects the standard input stream (stdin) of the process from the
* specified file.
*
* \param filePath Path to an existing file from which the process will
* read its standard input data. The current contents of
* the file won't be modified or affected in any way by
* calling this function.
*
* Example:
*
* \code
* ExternalProcess p;
* p.RedirectStandardInput( "/tmp/foo.txt" );
* p.Start( "grep", StringList() << "\'bar\'" );
* \endcode
*
* The above code snippet is equivalent to this command:
*
* <tt>grep 'bar' \</tmp/foo.txt</tt>
*
* \note This member function can only be called before running the process,
* i.e. before calling Start(). Otherwise an Error exception is thrown.
*/
void RedirectStandardInput( const String& filePath );
/*!
* Returns the working directory (aka folder) of this process.
*/
String WorkingDirectory() const;
/*!
* Sets the working directory for this process.
*
* \param dirPath Path to an existing directory, which will be the
* working directory of the process when it is started.
*
* \note This member function can only be called before running the process,
* i.e. before calling Start(). Otherwise an Error exception is thrown.
*/
void SetWorkingDirectory( const String& dirPath );
/*!
* Returns true iff the process is running. An %ExternalProcess object
* represents a running process briefly (usually) after calling its Start()
* member function, when the IsStarting() function returns false, and just
* before an OnStarted() event is generated.
*/
bool IsRunning() const;
/*!
* Returns true iff the process is starting. An %ExternalProcess object
* enters the starting state after calling its Start() member function, but
* before the actual process is running.
*/
bool IsStarting() const;
/*!
* Returns true iff the running process has crashed.
*/
bool HasCrashed() const;
/*!
* Returns the platform-dependent Process Identifier (PID) of the running
* process. See the ExternalProcess::pid_type type definition for more
* information.
*
* If the process is not running this member function returns zero.
*/
pid_type PID() const;
/*!
* Returns the exit code of the finished process. This is normally the
* return value of the process' main() function.
*/
int ExitCode() const;
/*!
* Returns the number of bytes waiting to be read from this running process.
* If the process is not running, this member function returns zero.
*
* When this function returns a nonzero value, the available data can be
* read by calling one of the Read() member functions.
*/
size_type BytesAvailable() const;
/*!
* Returns the number of bytes pending to be written to this running
* process. If the process is not running, this function returns zero.
*
* If this function returns a nonzero value, it is because one of the
* Write() member functions has been called previously for this process with
* nonempty data.
*/
size_type BytesToWrite() const;
/*!
* Reads all the data available from the standard output stream (stdout) of
* this process, and returns them as a ByteArray object.
*
* If the process has not sent any new data through its stdout stream, or if
* the process is not running, an empty %ByteArray is returned. Note that
* after the reading operation the stdout stream is cleared, i.e. the data
* can only be read once.
*/
ByteArray StandardOutput();
/*!
* Reads all the data available from the standard error stream (stderr) of
* this process, and returns them as a ByteArray object.
*
* If the process has not sent any new data through its stderr stream, or if
* the process is not running, an empty %ByteArray is returned. Note that
* after the reading operation the stderr stream is cleared, i.e. the data
* can only be read once.
*/
ByteArray StandardError();
/*!
* Reads all the data available from the standard output and standard error
* streams (stdout and stderr, respectively) of this process, and returns
* them as a ByteArray object.
*
* If the process has not sent any new data through its output streams, or
* if the process is not running, an empty %ByteArray is returned. Note that
* after the reading operation, both stdout and stderr streams are cleared,
* i.e. the data can only be read once.
*
* \note In the returned %ByteArray, the data from both stdout and stderr
* streams will be mixed because they are gathered as they are generated. If
* you need the data from both streams separately, call the StandardOutput()
* and StandardError() member functions as appropriate.
*/
ByteArray Read();
/*!
* Writes the specified \a data to the standard input stream (stdin) of this
* process.
*/
void Write( const ByteArray& data );
/*!
* Writes the specified \a text to the standard input stream (stdin) of this
* process. The specified UTF-16 string will be treated as a sequence of
* bytes, and the terminating null character of the string (two bytes) will
* be excluded.
*/
void Write( const String& text );
/*!
* Writes the specified \a text to the standard input stream (stdin) of this
* process. The specified 8-bit string will be treated as a sequence of
* bytes, and the terminating null character of the string will be excluded.
*/
void Write( const IsoString& text );
/*!
* Writes the specified \a text to the standard input stream (stdin) of this
* process. The specified 8-bit string will be treated as a sequence of
* bytes, and the terminating null character of the string will be excluded.
*/
void Write( const char* text );
/*!
* Writes \a count contiguous bytes starting at the specified \a data
* location to the standard input stream (stdin) of this process.
*/
void Write( const void* data, size_type count );
/*!
* Returns the list of environment variables for this process. Environment
* variables are 'name=value' items that most programs can interpret to
* modify their functionality.
*
* If no environment has been set for this process, an empty list is
* returned.
*/
StringList Environment() const;
/*!
* Sets the \a environment for this process.
*
* The environment is a list of 'name=value' elements, knwon as
* <em>environment variables</em>, that most programs can interpret to
* modify their functionality.
*
* If no environment is explicitly set for a process, it will inherit the
* environment of the calling process.
*
* \note This member function can only be called before running the process,
* i.e. before calling Start(). Otherwise an Error exception is thrown.
*/
void SetEnvironment( const StringList& environment );
/*!
* \defgroup external_process_event_handlers ExternalProcess Event Handlers
*/
/*!
* Defines the prototype of a <em>process event handler</em>.
*
* A process event is generated when an %ExternalProcess instance changes
* its state, or generates a simple notification.
*
* \param sender The object that sends a process event.
*
* \ingroup external_process_event_handlers
*/
typedef void (Control::*process_event_handler)( ExternalProcess& sender );
/*!
* Defines the prototype of a <em>process exit event handler</em>.
*
* A process exit event is generated when an %ExternalProcess instance
* notifies that a running process has finished execution.
*
* \param sender The object that sends a process exit event.
*
* \param exitCode The process' exit code. Typically, this is the return
* value of the main() function in the process.
*
* \param exitOk True if the process finished execution normally. False
* if the process crashed.
*
* \ingroup external_process_event_handlers
*/
typedef void (Control::*process_exit_event_handler)( ExternalProcess& sender, int exitCode, bool exitOk );
/*!
* Defines the prototype of a <em>process error event handler</em>.
*
* A process error event is generated when an %ExternalProcess instance
* reports an error condition, such as an I/O error, a nonexistent
* executable file or lack of execution permissions.
*
* \param sender The object that sends a process error event.
*
* \param error Identifies the error condition that generated the event.
*
* \ingroup external_process_event_handlers
*/
typedef void (Control::*process_error_event_handler)( ExternalProcess& sender, error_code error );
/*!
* Sets the handler for <em>process started</em> events generated by this
* %ExternalProcess object. A process started event is generated when the
* process has just started and is running.
*
* \param handler The event handler. Must be a member function of the
* \a receiver object's class.
*
* \param receiver The control that will receive process started events
* from this object.
*
* \ingroup external_process_event_handlers
*/
void OnStarted( process_event_handler handler, Control& receiver );
/*!
* Sets the handler for <em>process finished</em> events generated by this
* %ExternalProcess object. A process finished event is generated when the
* running process has just finished execution.
*
* \param handler The event handler. Must be a member function of the
* \a receiver object's class.
*
* \param receiver The control that will receive process finished events
* from this object.
*
* \ingroup external_process_event_handlers
*/
void OnFinished( process_exit_event_handler handler, Control& receiver );
/*!
* Sets the handler for <em>stdout data available</em> events generated by
* this %ExternalProcess object. These events are generated when the running
* process sends data through its standard output stream, and the data is
* ready to be read.
*
* \param handler The event handler. Must be a member function of the
* \a receiver object's class.
*
* \param receiver The control that will receive stdout data available
* events from this object.
*
* \ingroup external_process_event_handlers
*/
void OnStandardOutputDataAvailable( process_event_handler handler, Control& receiver );
/*!
* Sets the handler for <em>stderr data available</em> events generated by
* this %ExternalProcess object. These events are generated when the running
* process sends data through its standard error stream, and the data is
* ready to be read.
*
* \param handler The event handler. Must be a member function of the
* \a receiver object's class.
*
* \param receiver The control that will receive stderr data available
* events from this object.
*
* \ingroup external_process_event_handlers
*/
void OnStandardErrorDataAvailable( process_event_handler handler, Control& receiver );
/*!
* Sets the handler for <em>process error</em> events generated by this
* %ExternalProcess object. A process error event is generated when the
* process reports an error condition.
*
* \param handler The event handler. Must be a member function of the
* \a receiver object's class.
*
* \param receiver The control that will receive process error events
* from this object.
*
* \ingroup external_process_event_handlers
*/
void OnError( process_error_event_handler handler, Control& receiver );
/*!
* Executes a program as a child process and waits for it to terminate.
*
* \param program Path to an existing executable file.
*
* \param arguments Optional list of command-line arguments that will be
* passed to the executable. Arguments containing spaces
* will be enclosed by quotes automatically. The default
* value is an empty list.
*
* Returns the program's exit code. If the specified \a program cannot be
* executed, this member function throws an Error exception.
*/
static int ExecuteProgram( const String& program, const StringList& arguments = StringList() );
/*!
* Executes a program as an independent process.
*
* \param program Path to an existing executable file.
*
* \param arguments Optional list of command-line arguments that will be
* passed to the executable. Arguments containing spaces
* will be enclosed by quotes automatically. The default
* value is an empty list.
*
* \param workingDirectory Path to an existing directory, which will be the
* working directory of the process. The default value is
* an empty string.
*
* The program is executed as a standalone process, also known as a
* \e daemon on Linux/UNIX. It can continue running after the calling
* application terminates.
*
* Returns the platform-dependent process identifier (PID) of the running
* process. If the specified \a program cannot be executed, this member
* function throws an Error exception.
*/
static pid_type StartProgram( const String& program,
const StringList& arguments = StringList(),
const String& workingDirectory = String() );
private:
struct EventHandlers
{
process_event_handler onStarted = nullptr;
process_exit_event_handler onFinished = nullptr;
process_event_handler onStandardOutputDataAvailable = nullptr;
process_event_handler onStandardErrorDataAvailable = nullptr;
process_error_event_handler onError = nullptr;
EventHandlers() = default;
EventHandlers( const EventHandlers& ) = default;
EventHandlers& operator =( const EventHandlers& ) = default;
};
AutoPointer<EventHandlers> m_handlers;
ExternalProcess( void* );
void* CloneHandle() const override;
friend class ExternalProcessPrivate;
friend class ExternalProcessEventDispatcher;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
#endif // __PCL_ExternalProcess_h
// ----------------------------------------------------------------------------
// EOF pcl/ExternalProcess.h - Released 2022-03-12T18:59:29Z
-838
View File
@@ -1,838 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/FFT1D.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_FFT1D_h
#define __PCL_FFT1D_h
/// \file pcl/FFT1D.h
/*
* The FFT routines used in this PCL version are based on the KISS FFT library
* by Mark Borgerding: http://sourceforge.net/projects/kissfft/
*
* KISS FFT LICENSE INFORMATION
* ============================
*
* Copyright (c) 2003-2013 Mark Borgerding
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the author nor the names of any contributors may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <pcl/Defs.h>
#include <pcl/Complex.h>
#include <pcl/Vector.h>
namespace pcl
{
// ----------------------------------------------------------------------------
class FFT1DBase
{
protected:
static int OptimizedLength( int, fcomplex* );
static int OptimizedLength( int, dcomplex* );
static int OptimizedLength( int, float* );
static int OptimizedLength( int, double* );
static void* Create( int, fcomplex* );
static void* Create( int, dcomplex* );
static void* Create( int, float* );
static void* Create( int, double* );
static void* CreateInv( int, fcomplex* );
static void* CreateInv( int, dcomplex* );
static void* CreateInv( int, float* );
static void* CreateInv( int, double* );
static void Destroy( void* );
static void Transform( void*, fcomplex*, const fcomplex* );
static void Transform( void*, dcomplex*, const dcomplex* );
static void Transform( void*, fcomplex*, const float* );
static void Transform( void*, dcomplex*, const double* );
static void Transform( void*, float*, const fcomplex* );
static void Transform( void*, double*, const dcomplex* );
};
// ----------------------------------------------------------------------------
/*!
* \defgroup fft_1d Fast Fourier Transform Direction Specifiers
*/
/*!
* \def PCL_FFT_FORWARD
* \brief Indicates a Fourier transform.
* \ingroup fft_1d
*/
#define PCL_FFT_FORWARD -1
/*!
* \def PCL_FFT_BACKWARD
* \brief Indicates an inverse Fourier transform.
* \ingroup fft_1d
*/
#define PCL_FFT_BACKWARD +1
// ----------------------------------------------------------------------------
/*!
* \class AbstractFFT
* \brief Abstract base class of all fast Fourier transform classes
*
* The %AbstractFFT template class implements basic properties and functions
* shared by all %FFT PCL classes.
*
* \sa GenericFFT, GenericRealFFT
*/
template <typename T>
class PCL_CLASS AbstractFFT : public FFT1DBase
{
public:
/*!
* Represents a scalar in the context of this %FFT class.
*/
typedef T scalar;
/*!
* Represents a complex number in the context of this %FFT class.
*/
typedef Complex<T> complex;
/*!
* Represents a vector of real numbers.
*/
typedef GenericVector<scalar> vector;
/*!
* Represents a vector of complex numbers.
*/
typedef GenericVector<complex> complex_vector;
/*!
* Represents the container type used to store an out-of-place discrete
* Fourier transform.
*/
typedef complex_vector transform;
/*!
* Constructs an %AbstractFFT object of the specified \a length.
*/
AbstractFFT( int length )
: m_length( length )
{
}
/*!
* Virtual destructor.
*
* Destroys all internal control structures in this %AbstractFFT object,
* including the current discrete Fourier transform, if it exists.
*/
virtual ~AbstractFFT()
{
Release();
}
/*!
* Returns the transform length of this %AbstractFFT object. The length is
* the number of data items that can be transformed, and is specified in the
* constructors of all %FFT classes.
*/
int Length() const
{
return m_length;
}
/*!
* Returns a duplicate of the current discrete Fourier transform as a vector
* of complex values.
*
* For complex FFTs, the returned vector has Length() elements. For real
* transforms, the returned vector has Length()/2 + 1 elements.
*
* If no %FFT has been performed on this object, this function returns an
* empty vector.
*/
transform DFT() const
{
return m_dft;
}
/*!
* Returns a reference to the mutable current discrete Fourier transform in
* this object. The transform is a vector of complex values.
*
* For complex FFTs, the returned vector has Length() elements. For real
* transforms, the returned vector has Length()/2 + 1 elements.
*
* If no %FFT has been performed on this object, this function returns a
* reference to an empty vector.
*/
transform& DFT()
{
return m_dft;
}
/*!
* Returns a pointer to the immutable first element in the current discrete
* Fourier transform. The transform is a set of consecutive complex numbers
* stored at the address returned by this member function.
*
* For complex FFTs, the transform is a sequence of Length() elements. For
* real transforms, there are only Length()/2 + 1 elements.
*
* If no %FFT has been performed on this object, this member function
* returns zero.
*/
const complex* operator *() const
{
return *m_dft;
}
/*!
* Returns a pointer to the mutable first element in the current discrete
* Fourier transform. The transform is a set of consecutive complex numbers
* stored at the address returned by this member function.
*
* For complex FFTs, the transform is a sequence of Length() elements. For
* real transforms, there are only Length()/2 + 1 elements.
*
* If no %FFT has been performed on this object, this member function
* returns zero.
*/
complex* operator *()
{
return *m_dft;
}
/*!
* Destroys all internal control structures in this %AbstractFFT object,
* including the current discrete Fourier transform, if it exists.
*/
virtual void Release()
{
if ( m_handle != nullptr )
this->Destroy( m_handle ), m_handle = nullptr;
if ( m_handleInv != nullptr )
this->Destroy( m_handleInv ), m_handleInv = nullptr;
m_dft = transform();
}
private:
int m_length;
protected:
mutable void* m_handle = nullptr; // Opaque pointers to internal control structures
mutable void* m_handleInv = nullptr;
transform m_dft; // DFT of complex or real data
};
// ----------------------------------------------------------------------------
#define m_handle this->m_handle
#define m_handleInv this->m_handleInv
#define m_dft this->m_dft
#define m_length this->Length()
// ----------------------------------------------------------------------------
/*!
* \class GenericFFT
* \brief Generic fast Fourier transform of complex data
*
* The %GenericFFT template class performs forward and inverse, out-of-place
* fast Fourier transforms of complex data.
*
* For fast Fourier transforms of real-valued data, see the GenericRealFFT
* template class.
*
* \sa AbstractFFT, GenericRealFFT
*/
template <typename T>
class PCL_CLASS GenericFFT : public AbstractFFT<T>
{
public:
/*!
* Identifies the base class of this %FFT class.
*/
typedef AbstractFFT<T> base;
/*!
* Represents a scalar in the context of this %FFT class.
*/
typedef typename base::scalar scalar;
/*!
* Represents a complex number in the context of this %FFT class.
*/
typedef typename base::complex complex;
/*!
* Represents a vector of real numbers.
*/
typedef typename base::vector vector;
/*!
* Represents a vector of complex numbers.
*/
typedef typename base::complex_vector complex_vector;
/*!
* Represents the container type used to store an out-of-place discrete
* Fourier transform.
*/
typedef typename base::transform transform;
/*!
* Constructs a %GenericFFT object of the specified length \a n.
*
* The current PCL implementation supports FFTs of arbitrary length, but the
* underlying routines have been optimized for performance when the length
* of the input vector can be factorized as follows:
*
* <tt>n = 2^n2 * 3^n3 * 4^n4 * 5^n5</tt>
*
* where n2, n3, n4, and n5 are arbitrary positive integers. For best
* performance, you should call GenericFFT::OptimizedLength() to get the
* smallest optimal length for your data, then place them on an array of the
* obtained length, padded with zeros.
*/
GenericFFT( int n )
: base( n )
{
}
/*!
* Virtual destructor.
*/
virtual ~GenericFFT()
{
}
/*!
* Fast Fourier transform. Performs the %FFT of the specified vector of
* complex values.
*
* The argument \a x must be the starting address of a contiguous block of
* at least Length() elements.
*
* Returns a reference to this object.
*/
GenericFFT& operator <<( const complex* x )
{
if ( m_dft.IsEmpty() )
m_dft = transform( m_length );
if ( m_handle == nullptr )
m_handle = this->Create( m_length, static_cast<complex*>( nullptr ) );
this->Transform( m_handle, *m_dft, x );
return *this;
}
/*!
* Inverse fast Fourier transform. Performs the inverse %FFT and stores the
* result in the specified vector of complex values.
*
* The argument \a y must be the starting address of a contiguous block of
* at least Length() elements.
*
* If no %FFT has been performed on this object (by a previous call to
* operator <<()), this member function throws an Error exception.
*
* Returns a reference to this object.
*/
GenericFFT& operator >>( complex* y ) const
{
if ( m_dft.IsEmpty() )
throw Error( "Invalid out-of-place inverse FFT: No FFT has been performed." );
if ( m_handleInv == nullptr )
m_handleInv = this->CreateInv( m_length, static_cast<complex*>( nullptr ) );
this->Transform( m_handleInv, y, *m_dft );
return *this;
}
/*!
* Fast Fourier transform. Performs the %FFT of a vector of complex values.
*
* The specified vector \a x must have at least Length() elements. Otherwise
* an Error exception will be thrown.
*
* Returns a reference to this object.
*/
GenericFFT& operator <<( const complex_vector& x )
{
PCL_PRECONDITION( x.Length() >= m_length )
if ( x.Length() < m_length )
throw Error( "Invalid FFT input vector length." );
return operator <<( *x );
}
/*!
* Inverse fast Fourier transform. Performs the inverse %FFT and stores the
* result in a vector of complex values.
*
* The specified vector \a y must have at least Length() elements. Otherwise
* an Error exception will be thrown.
*
* If no %FFT has been performed on this object (by a previous call to
* operator <<()), this member function throws an Error exception.
*
* Returns a reference to this object.
*/
GenericFFT& operator >>( complex_vector& y ) const
{
if ( y.Length() < m_length )
throw Error( "Invalid FFT output vector length." );
return operator >>( *y );
}
/*!
* Performs the forward or inverse %FFT of an input vector of complex
* values, and stores the result in a caller-supplied output vector.
*
* \param[in] x Input vector. Must be the starting address of a contiguous
* sequence of at least Length() complex numbers.
*
* \param[out] y Output vector, where the result of the transform will be
* stored. Must be the starting address of a contiguous
* sequence of at least Length() complex numbers.
*
* \param dir Indicates the direction of the Fourier transform:\n
* \n
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>PCL_FFT_FORWARD</td> <td>The direct FFT is calculated.</td></tr>
* <tr><td>PCL_FFT_BACKWARD</td> <td>The inverse FFT is calculated.</td></tr>
* </table>\n
* \n
* This parameter is optional; the default value is
* PCL_FFT_FORWARD.
*
* The specified arguments \a x and \a y must be the starting addresses of
* two different, non-overlapping contiguous blocks of at least Length()
* elements.
*
* This member function does not change the current Fourier transform in
* this object, if it exists.
*
* Returns a reference to this object.
*/
GenericFFT& operator()( complex* y, const complex* x, int dir = PCL_FFT_FORWARD ) const
{
if ( dir == PCL_FFT_BACKWARD )
{
if ( m_handleInv == nullptr )
m_handleInv = this->CreateInv( m_length, static_cast<complex*>( nullptr ) );
this->Transform( m_handleInv, y, x );
}
else
{
if ( m_handle == nullptr )
m_handle = this->Create( m_length, static_cast<complex*>( nullptr ) );
this->Transform( m_handle, y, x );
}
return const_cast<GenericFFT&>( *this );
}
/*!
* Returns the <em>optimized complex %FFT length</em> larger than or equal to
* a given length \a n. The returned length will be optimal to perform a
* %FFT of complex data with the current PCL implementation. The optimized
* length can be used as the argument to the constructor of any %FFT class for
* complex data transforms.
*/
static int OptimizedLength( int n )
{
return FFT1DBase::OptimizedLength( n, static_cast<complex*>( nullptr ) );
}
};
// ----------------------------------------------------------------------------
/*!
* \class GenericRealFFT
* \brief Generic fast Fourier transform of real data
*
* The %GenericRealFFT template class performs forward and inverse,
* out-of-place fast Fourier transforms of real-valued data. For real data in
* the time domain, this class performs nearly twice as fast as Fourier
* transform classes for complex data.
*
* For fast Fourier transforms of complex-valued data, see the GenericFFT
* template class.
*
* \sa AbstractFFT, GenericFFT
*/
template <typename T>
class PCL_CLASS GenericRealFFT : public AbstractFFT<T>
{
public:
/*!
* Identifies the base class of this %FFT class.
*/
typedef AbstractFFT<T> base;
/*!
* Represents a scalar in the context of this %FFT class.
*/
typedef typename base::scalar scalar;
/*!
* Represents a complex number in the context of this %FFT class.
*/
typedef typename base::complex complex;
/*!
* Represents a vector of real numbers.
*/
typedef typename base::vector vector;
/*!
* Represents a vector of complex numbers.
*/
typedef typename base::complex_vector complex_vector;
/*!
* Represents the container type used to store an out-of-place discrete
* Fourier transform.
*/
typedef typename base::transform transform;
/*!
* Constructs a %GenericRealFFT object of the specified \a length.
*
* The current PCL implementation supports FFTs for real data of any even
* length, but the underlying routines have been optimized for performance
* when the length of the input vector can be factorized as follows:
*
* <tt>n = 2^n2 * 3^n3 * 4^n4 * 5^n5</tt>
*
* where n2, n3, n4, and n5 are arbitrary positive integers, and n is an
* even integer. For best performance, you should call
* GenericRealFFT::OptimizedLength() to get the smallest optimal length for
* your real data, then place them on an array of the obtained length,
* padded with zeros.
*
* \note We stress the fact that the specified \a length must be an \e even
* integer.
*/
GenericRealFFT( int length )
: base( length )
{
PCL_PRECONDITION( (length & 1) == 0 )
}
/*!
* Virtual destructor.
*/
virtual ~GenericRealFFT()
{
}
/*!
* Fast Fourier transform. Performs the %FFT of the specified vector of
* real numbers.
*
* The argument \a x must be the starting address of a contiguous block of
* at least Length() scalars.
*
* Returns a reference to this object.
*/
GenericRealFFT& operator <<( const scalar* x )
{
if ( m_dft.IsEmpty() )
m_dft = transform( m_length/2 + 1 );
if ( m_handle == nullptr )
m_handle = this->Create( m_length, static_cast<scalar*>( nullptr ) );
this->Transform( m_handle, *m_dft, x );
return *this;
}
/*!
* Inverse fast Fourier transform. Performs the inverse %FFT and stores the
* result in the specified vector of real values.
*
* The value of \a y must be the starting address of a contiguous block of
* at least Length() elements.
*
* If no %FFT has been performed for this object (by a previous call to
* operator <<()), this member function throws an Error exception.
*
* Returns a reference to this object.
*/
GenericRealFFT& operator >>( scalar* y ) const
{
if ( m_dft.IsEmpty() )
throw Error( "Invalid out-of-place inverse FFT: No FFT has been performed." );
if ( m_handleInv == nullptr )
m_handleInv = this->CreateInv( m_length, static_cast<scalar*>( nullptr ) );
this->Transform( m_handleInv, y, *m_dft );
return *this;
}
/*!
* Fast Fourier transform. Performs the %FFT of a vector of real numbers.
*
* The specified vector \a x must have at least Length() elements. Otherwise
* an Error exception will be thrown.
*
* Returns a reference to this object.
*/
GenericRealFFT& operator <<( const vector& x )
{
if ( x.Length() < m_length )
throw Error( "Invalid FFT input vector length." );
return operator <<( *x );
}
/*!
* Inverse fast Fourier transform. Performs the inverse %FFT and stores the
* result in the specified vector of real values.
*
* The specified vector \a y must have at least Length() elements. Otherwise
* an Error exception will be thrown.
*
* If no %FFT has been performed on this object (by a previous call to
* operator <<()), this member function throws an Error exception.
*
* Returns a reference to this object.
*/
GenericRealFFT& operator >>( vector& y ) const
{
if ( y.Length() < m_length )
throw Error( "Invalid FFT output vector length." );
return operator >>( *y );
}
/*!
* Performs the %FFT of an input vector of real numbers, and stores the
* result in a caller-supplied output vector of complex values.
*
* \param[in] x Input vector. Must be the starting address of a contiguous
* sequence of at least Length() scalars.
*
* \param[out] y Output vector, where the result of the transform will be
* stored. Must be the starting address of a contiguous
* sequence of at least Length()/2 + 1 complex numbers.
*
* The specified arguments \a x and \a y must be the starting addresses of
* two different, non-overlapping contiguous blocks of data. The output
* transform will be a sequence of Length()/2 + 1 complex numbers.
*
* This member function does not change the current Fourier transform in
* this object, if any.
*
* Returns a reference to this object.
*/
GenericRealFFT& operator()( complex* y, const scalar* x ) const
{
if ( m_handle == nullptr )
m_handle = this->Create( m_length, static_cast<scalar*>( nullptr ) );
this->Transform( m_handle, y, x );
return const_cast<GenericRealFFT&>( *this );
}
/*!
* Performs the inverse %FFT of an input vector of complex numbers, and
* stores the result in a caller-supplied output vector of real values.
*
* \param[in] x Input vector. Must be the starting address of a contiguous
* sequence of at least Length()/2 + 1 complex numbers,
* corresponding to a discrete real Fourier transform of
* length Length().
*
* \param[out] y Output vector, where the result of the inverse transform
* will be stored. Must be the starting address of a
* contiguous sequence of at least Length() real numbers.
*
* The specified arguments \a x and \a y must be the starting addresses of
* two different, non-overlapping contiguous blocks of data. The input
* transform must be a sequence of Length()/2 + 1 complex numbers. The
* output inverse transform will be a sequence of Length() real numbers.
*
* This member function does not change the current Fourier transform in
* this object, if any.
*
* Returns a reference to this object.
*/
GenericRealFFT& operator()( scalar* y, const complex* x ) const
{
if ( m_handleInv == nullptr )
m_handleInv = this->CreateInv( m_length, static_cast<scalar*>( nullptr ) );
this->Transform( m_handleInv, y, x );
return const_cast<GenericRealFFT&>( *this );
}
/*!
* Returns the <em>optimized real %FFT length</em> larger than or equal to a
* given length \a n. The returned length will be optimal to perform a %FFT
* of real data with the current PCL implementation. The optimized length
* can be used as the argument to the constructor of any %FFT class for
* real data transforms.
*/
static int OptimizedLength( int n )
{
return FFT1DBase::OptimizedLength( n, static_cast<scalar*>( nullptr ) );
}
};
// ----------------------------------------------------------------------------
#undef m_handle
#undef m_handleInv
#undef m_dft
#undef m_length
// ----------------------------------------------------------------------------
#ifndef __PCL_NO_FFT1D_INSTANTIATE
/*!
* \defgroup fft_types_1d Fast Fourier Transforms
*/
/*!
* \class pcl::FFFT
* \ingroup fft_types_1d
* \brief Fast Fourier transform of 32-bit floating point complex data.
*
* %FFFT is a template instantiation of GenericFFT for the \c float type.
*/
typedef GenericFFT<float> FFFT;
/*!
* \class pcl::DFFT
* \ingroup fft_types_1d
* \brief Fast Fourier transform of 64-bit floating point complex data.
*
* %DFFT is a template instantiation of GenericFFT for the \c double type.
*/
typedef GenericFFT<double> DFFT;
/*!
* \class pcl::FRealFFT
* \ingroup fft_types_1d
* \brief Fast Fourier transform of 32-bit floating point real data.
*
* %FRealFFT is a template instantiation of GenericRealFFT for \c float.
*/
typedef GenericRealFFT<float> FRealFFT;
/*!
* \class pcl::DRealFFT
* \ingroup fft_types_1d
* \brief Fast Fourier transform of 64-bit floating point real data.
*
* %DRealFFT is a template instantiation of GenericRealFFT for \c double.
*/
typedef GenericRealFFT<double> DRealFFT;
/*!
* \class pcl::FFT
* \ingroup fft_types_1d
* \brief Fast Fourier transform of 32-bit floating point complex data.
*
* %FFT is an alias for FFFT. It is a template instantiation of GenericFFT for
* the \c float type.
*/
typedef FFFT FFT;
/*!
* \class pcl::RealFFT
* \ingroup fft_types_1d
* \brief Fast Fourier transform of 32-bit floating point real data.
*
* %RealFFT is an alias for FRealFFT. It is a template instantiation of
* GenericRealFFT for the \c float type.
*/
typedef FRealFFT RealFFT;
#endif // __PCL_NO_FFT1D_INSTANTIATE
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_FFT1D_h
// ----------------------------------------------------------------------------
// EOF pcl/FFT1D.h - Released 2022-03-12T18:59:29Z
-869
View File
@@ -1,869 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/FFT2D.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_FFT2D_h
#define __PCL_FFT2D_h
/// \file pcl/FFT2D.h
/*
* The FFT routines used in this PCL version are based on the KISS FFT library
* by Mark Borgerding: http://sourceforge.net/projects/kissfft/
*
* KISS FFT LICENSE INFORMATION
* ============================
*
* Copyright (c) 2003-2009 Mark Borgerding
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the author nor the names of any contributors may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <pcl/Defs.h>
#include <pcl/FFT1D.h>
#include <pcl/Matrix.h>
#include <pcl/ParallelProcess.h>
#include <pcl/StatusMonitor.h>
namespace pcl
{
// ----------------------------------------------------------------------------
class FFT2DBase
{
protected:
static void Transform( int, int, fcomplex*, const fcomplex*, int, StatusMonitor*, bool, int );
static void Transform( int, int, dcomplex*, const dcomplex*, int, StatusMonitor*, bool, int );
static void Transform( int, int, fcomplex*, const float*, StatusMonitor*, bool, int );
static void Transform( int, int, dcomplex*, const double*, StatusMonitor*, bool, int );
static void Transform( int, int, float*, const fcomplex*, StatusMonitor*, bool, int );
static void Transform( int, int, double*, const dcomplex*, StatusMonitor*, bool, int );
};
// ----------------------------------------------------------------------------
/*!
* \class AbstractFFT2D
* \brief Abstract base class of all two-dimensional fast Fourier transform classes
*
* The %AbstractFFT2D template class implements basic properties and functions
* shared by all 2-D %FFT PCL classes.
*
* \sa GenericFFT2D, GenericRealFFT2D
*/
template <typename T>
class PCL_CLASS AbstractFFT2D : public FFT2DBase, public ParallelProcess
{
public:
/*!
* Represents a scalar in the context of this %FFT class.
*/
typedef T scalar;
/*!
* Represents a complex number in the context of this %FFT class.
*/
typedef Complex<T> complex;
/*!
* Represents a vector of real numbers.
*/
typedef GenericVector<scalar> vector;
/*!
* Represents a vector of complex numbers.
*/
typedef GenericVector<complex> complex_vector;
/*!
* Represents a real matrix.
*/
typedef GenericMatrix<scalar> matrix;
/*!
* Represents a complex matrix.
*/
typedef GenericMatrix<complex> complex_matrix;
/*!
* Represents a discrete Fourier transform matrix.
*/
typedef complex_matrix transform;
/*!
* Constructs an %AbstractFFT2D object of the specified dimensions
* \a rows and \a cols.
*/
AbstractFFT2D( int rows, int cols )
: m_rows( rows )
, m_cols( cols )
{
}
/*!
* Constructs an %AbstractFFT2D object of the specified dimensions
* \a rows and \a cols, using the specified status \a monitor object.
*
* On each transform performed with this object, the status monitor will be
* incremented by the sum of transform dimensions: \a rows + \a cols.
*/
AbstractFFT2D( int rows, int cols, StatusMonitor& monitor )
: m_rows( rows )
, m_cols( cols )
, m_monitor( &monitor )
{
}
/*!
* Virtual destructor.
*
* Destroys all internal control structures in this %AbstractFFT2D object,
* including the current discrete Fourier transform, if exists.
*/
virtual ~AbstractFFT2D()
{
Release();
}
/*!
* Returns the number of rows in the 2-D transform of this %AbstractFFT2D
* object. Transform dimensions are specified in the constructors of all 2-D
* %FFT classes.
*/
int Rows() const
{
return m_rows;
}
/*!
* Returns the number of columns in the 2-D transform of this %AbstractFFT2D
* object. Transform dimensions are specified in the constructors of all 2-D
* %FFT classes.
*/
int Cols() const
{
return m_cols;
}
/*!
* Returns the total number of matrix elements in the 2-D data set of this
* %AbstractFFT2D object, or Rows() multiplied by Cols(). The dimensions are
* specified in the constructors of all 2-D %FFT classes.
*/
int NumberOfElements() const
{
return m_rows*m_cols;
}
/*!
* Returns a duplicate of the current discrete Fourier transform as a matrix
* of complex values.
*
* For complex data transforms, the returned matrix has Rows()*Cols()
* elements. For real data, the returned matrix has Rows()*(Cols()/2 + 1)
* elements.
*
* If no %FFT has been performed on this object, this function returns an
* empty matrix.
*/
transform DFT() const
{
return m_dft;
}
/*!
* Returns a non-const reference to the current discrete Fourier transform
* in this object. The transform is a matrix of complex values.
*
* For complex data transforms, the returned matrix has Rows()*Cols()
* elements. For real data, the returned matrix has Rows()*(Cols()/2 + 1)
* elements.
*
* If no %FFT has been performed on this object, this function returns a
* reference to an empty matrix.
*/
transform& DFT()
{
return m_dft;
}
/*!
* Destroys all internal control structures in this %FFT object, including
* the current Fourier transform, if exists.
*/
virtual void Release()
{
m_dft = transform();
}
private:
// Transform dimensions
int m_rows;
int m_cols;
protected:
transform m_dft; // DFT of complex or real data
StatusMonitor* m_monitor = nullptr;
};
// ----------------------------------------------------------------------------
#define m_dft this->m_dft
#define m_rows this->Rows()
#define m_cols this->Cols()
#define m_monitor this->m_monitor
#define m_parallel this->m_parallel
#define m_maxProcessors this->m_maxProcessors
// ----------------------------------------------------------------------------
/*!
* \class GenericFFT2D
* \brief Generic two-dimensional fast Fourier transform of complex data
*
* The %GenericFFT2D template class performs two-dimensional forward and
* inverse, out-of-place fast Fourier transforms of complex data.
*
* For fast Fourier transforms of 2-D real-valued data, see the
* GenericRealFFT2D template class.
*
* \sa AbstractFFT2D, GenericRealFFT2D
*/
template <typename T>
class PCL_CLASS GenericFFT2D : public AbstractFFT2D<T>
{
public:
/*!
* Identifies the base class of this %FFT class.
*/
typedef AbstractFFT2D<T> base;
/*!
* Represents a scalar in the context of this %FFT class.
*/
typedef typename base::scalar scalar;
/*!
* Represents a complex number in the context of this %FFT class.
*/
typedef typename base::complex complex;
/*!
* Represents a vector of real numbers.
*/
typedef typename base::vector vector;
/*!
* Represents a vector of complex numbers.
*/
typedef typename base::complex_vector complex_vector;
/*!
* Represents a real matrix.
*/
typedef typename base::matrix matrix;
/*!
* Represents a complex matrix.
*/
typedef typename base::complex_matrix complex_matrix;
/*!
* Represents a discrete Fourier transform matrix.
*/
typedef typename base::transform transform;
/*!
* Constructs a %GenericFFT2D object of the specified dimensions \a rows and
* \a cols.
*
* The current PCL implementation supports FFTs of arbitrary length, but the
* underlying routines have been optimized for performance when the length
* of the input vector can be factorized as follows:
*
* <tt>n = 2^n2 * 3^n3 * 4^n4 * 5^n5</tt>
*
* where n2, n3, n4, and n5 are arbitrary positive integers. For best
* performance, you should call GenericFFT2D::OptimizedLength() to get the
* smallest optimal dimensions for your data, then place them on a matrix of
* the obtained dimensions, padded with zeros.
*/
GenericFFT2D( int rows, int cols )
: base( rows, cols )
{
}
/*!
* Constructs a %GenericFFT2D object of the specified dimensions \a rows and
* \a cols, using the specified status monitoring object \a status.
*
* On each transform performed with this object, the status m_monitor will be
* incremented by the sum of transform dimensions: \a rows + \a cols.
*
* See the GenericFFT2D( int, int ) constructor for more information.
*/
GenericFFT2D( int rows, int cols, StatusMonitor& status )
: base( rows, cols, status )
{
}
/*!
* Virtual destructor.
*/
virtual ~GenericFFT2D()
{
}
/*!
* Fast Fourier transform. Performs the two-dimensional %FFT of the
* specified matrix of complex values.
*
* The argument \a x must be the starting address of a contiguous block of
* at least NumberOfElements() elements, stored in row order: all elements
* of the first matrix row followed by all elements of the second row, and
* so on.
*
* Returns a reference to this object.
*/
GenericFFT2D& operator <<( const complex* x )
{
if ( m_dft.IsEmpty() )
m_dft = transform( m_rows, m_cols );
this->Transform( m_rows, m_cols, *m_dft, x, PCL_FFT_FORWARD, m_monitor, m_parallel, m_maxProcessors );
return *this;
}
/*!
* Inverse fast Fourier transform. Performs the two-dimensional inverse %FFT
* and stores the result in the specified matrix of complex values.
*
* The argument \a y must be the starting address of a contiguous block of
* at least NumberOfElements() elements. The result matrix will be stored in
* row order: all elements of the first matrix row followed by all elements
* of the second row, and so on.
*
* If no %FFT has been performed on this object (by a previous call to
* operator <<()), this member function throws an Error exception.
*
* Returns a reference to this object.
*/
GenericFFT2D& operator >>( complex* y ) const
{
if ( m_dft.IsEmpty() )
throw Error( "Invalid out-of-place inverse FFT: No FFT has been performed." );
this->Transform( m_rows, m_cols, y, *m_dft, PCL_FFT_BACKWARD, m_monitor, m_parallel, m_maxProcessors );
return *this;
}
/*!
* Fast Fourier transform. Performs the two-dimensional %FFT of a matrix of
* complex values.
*
* The specified matrix \a x must have Rows() and Cols() dimensions.
* Otherwise an Error exception will be thrown.
*
* Returns a reference to this object.
*/
GenericFFT2D& operator <<( const complex_matrix& x )
{
PCL_PRECONDITION( x.Rows() == m_rows )
PCL_PRECONDITION( x.Cols() == m_cols )
if ( x.Rows() != m_rows || x.Cols() != m_cols )
throw Error( "Invalid FFT input matrix dimensions." );
return operator <<( *x );
}
/*!
* Inverse fast Fourier transform. Performs the two-dimensional inverse %FFT
* and stores the result in a matrix of complex values.
*
* The specified matrix \a y must have Rows() and Cols() dimensions.
* Otherwise an Error exception will be thrown.
*
* If no %FFT has been performed on this object (by a previous call to
* operator <<()), this member function throws an Error exception.
*
* Returns a reference to this object.
*/
GenericFFT2D& operator >>( complex_matrix& y ) const
{
PCL_PRECONDITION( y.Rows() == m_rows )
PCL_PRECONDITION( y.Cols() == m_cols )
if ( y.Rows() != m_rows || y.Cols() != m_cols )
throw Error( "Invalid FFT output matrix dimensions." );
return operator >>( *y );
}
/*!
* Performs the forward or inverse two-dimensional %FFT of an input matrix
* of complex values, and stores the result in a caller-supplied output
* matrix.
*
* \param[in] x Input matrix. Must be the starting address of a contiguous
* sequence of at least NumberOfElements() complex numbers,
* stored in row order: all elements of the first row
* followed by all elements of the second row, and so on.
*
* \param[out] y Output matrix, where the result of the transform will be
* stored. Must be the starting address of a contiguous
* sequence of at least NumberOfElements() complex numbers.
* The result will be stored in row order: all elements of
* the first row followed by all elements of the second row,
* and so on.
*
* \param dir Indicates the direction of the Fourier transform:\n
* \n
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>PCL_FFT_FORWARD</td> <td>The FFT is calculated.</td></tr>
* <tr><td>PCL_FFT_BACKWARD</td> <td>The inverse FFT is calculated.</td></tr>
* </table>\n
* \n
* This parameter is optional; the default value is
* PCL_FFT_FORWARD.
*
* This member function does not change the current Fourier transform in
* this object, if it exists.
*
* Returns a reference to this object.
*/
GenericFFT2D& operator ()( complex* y, const complex* x, int dir = PCL_FFT_FORWARD ) const
{
this->Transform( m_rows, m_cols, y, x, dir, m_monitor, m_parallel, m_maxProcessors );
return const_cast<GenericFFT2D&>( *this );
}
/*!
* Returns the <em>optimized complex %FFT length</em> larger than or equal to
* a given length \a n. The returned length will be optimal to perform a
* %FFT of complex data with the current PCL implementation. The optimized
* length can be used as the \a rows or \a cols argument to the constructor
* of any two-dimensional %FFT class for complex data transforms.
*/
static int OptimizedLength( int n )
{
return GenericFFT<T>::OptimizedLength( n );
}
};
// ----------------------------------------------------------------------------
/*!
* \class GenericRealFFT2D
* \brief Generic two-dimensional fast Fourier transform of real data
*
* The %GenericRealFFT2D template class performs forward and inverse,
* out-of-place fast two-dimensional Fourier transforms of real-valued data.
* For real data in the time domain, this class performs nearly twice as fast
* as Fourier transform classes for complex data.
*
* For two-dimensional fast Fourier transforms of complex-valued data, see the
* GenericFFT2D template class.
*
* \sa AbstractFFT2D, GenericFFT2D
*/
template <typename T>
class PCL_CLASS GenericRealFFT2D : public AbstractFFT2D<T>
{
public:
/*!
* Identifies the base class of this %FFT class.
*/
typedef AbstractFFT2D<T> base;
/*!
* Represents a scalar in the context of this %FFT class.
*/
typedef typename base::scalar scalar;
/*!
* Represents a complex number in the context of this %FFT class.
*/
typedef typename base::complex complex;
/*!
* Represents a vector of real numbers.
*/
typedef typename base::vector vector;
/*!
* Represents a vector of complex numbers.
*/
typedef typename base::complex_vector complex_vector;
/*!
* Represents a real matrix.
*/
typedef typename base::matrix matrix;
/*!
* Represents a complex matrix.
*/
typedef typename base::complex_matrix complex_matrix;
/*!
* Represents a discrete Fourier transform matrix.
*/
typedef typename base::transform transform;
/*!
* Constructs a %GenericRealFFT2D object of the specified dimensions \a rows
* and \a cols.
*
* The current PCL implementation supports FFTs for real data of any even
* length, but the underlying routines have been optimized for performance
* when the length of the input vector can be factorized as follows:
*
* <tt>n = 2^n2 * 3^n3 * 4^n4 * 5^n5</tt>
*
* where n2, n3, n4, and n5 are arbitrary positive integers, and n is an
* even integer. For best performance, you should call
* GenericRealFFT2D::OptimizedLength() to get the smallest optimal
* dimensions for your real-valued data, then place them on a matrix of the
* obtained dimensions, padded with zeros.
*
* \note We stress the fact that the specified dimensions \a rows and
* \a cols must be \e even integer numbers.
*/
GenericRealFFT2D( int rows, int cols )
: base( rows, cols )
{
}
/*!
* Constructs a %GenericRealFFT2D object of the specified dimensions \a rows
* and \a cols, using the specified status monitoring object \a status.
*
* On each transform performed with this object, the status m_monitor will be
* incremented by the sum of transform dimensions: \a rows + \a cols.
*
* See the GenericRealFFT2D( int, int ) constructor for more information.
*/
GenericRealFFT2D( int rows, int cols, StatusMonitor& status )
: base( rows, cols, status )
{
}
/*!
* Virtual destructor.
*/
virtual ~GenericRealFFT2D()
{
}
/*!
* Fast Fourier transform. Performs the two-dimensional %FFT of the
* specified matrix of real values.
*
* The argument \a x must be the starting address of a contiguous block of
* at least NumberOfElements() elements, stored in row order: all elements
* of the first matrix row followed by all elements of the second row, and
* so on.
*
* Returns a reference to this object.
*/
GenericRealFFT2D& operator <<( const scalar* x )
{
if ( m_dft.IsEmpty() )
m_dft = transform( m_rows, m_cols/2 + 1 );
this->Transform( m_rows, m_cols, *m_dft, x, m_monitor, m_parallel, m_maxProcessors );
return *this;
}
/*!
* Inverse fast Fourier transform. Performs the two-dimensional inverse %FFT
* and stores the result in the specified matrix of real values.
*
* The argument \a y must be the starting address of a contiguous block of
* at least NumberOfElements() elements. The result matrix will be stored in
* row order: all elements of the first matrix row followed by all elements
* of the second row, and so on.
*
* If no %FFT has been performed on this object (by a previous call to
* operator <<()), this member function throws an Error exception.
*
* Returns a reference to this object.
*/
GenericRealFFT2D& operator >>( scalar* y ) const
{
if ( m_dft.IsEmpty() )
throw Error( "Invalid out-of-place inverse FFT: No FFT has been performed." );
this->Transform( m_rows, m_cols, y, *m_dft, m_monitor, m_parallel, m_maxProcessors );
return *this;
}
/*!
* Fast Fourier transform. Performs the two-dimensional %FFT of a matrix of
* real numbers.
*
* The specified matrix \a x must have Rows() and Cols() dimensions.
* Otherwise an Error exception will be thrown.
*
* Returns a reference to this object.
*/
GenericRealFFT2D& operator <<( const matrix& x )
{
PCL_PRECONDITION( x.Rows() == m_rows )
PCL_PRECONDITION( x.Cols() == m_cols )
if ( x.Rows() != m_rows || x.Cols() != m_cols )
throw Error( "Invalid FFT input matrix dimensions." );
return operator <<( *x );
}
/*!
* Inverse fast Fourier transform. Performs the two-dimensional inverse %FFT
* and stores the result in a matrix of real numbers.
*
* The specified matrix \a y must have Rows() and Cols() dimensions.
* Otherwise an Error exception will be thrown.
*
* If no %FFT has been performed on this object (by a previous call to
* operator <<()), this member function throws an Error exception.
*
* Returns a reference to this object.
*/
GenericRealFFT2D& operator >>( matrix& y ) const
{
PCL_PRECONDITION( y.Rows() == m_rows )
PCL_PRECONDITION( y.Cols() == m_cols )
if ( y.Rows() != m_rows || y.Cols() != m_cols )
throw Error( "Invalid FFT output matrix dimensions." );
return operator >>( *y );
}
/*!
* Performs the two-dimensional %FFT of an input matrix of real numbers, and
* stores the result in an output matrix of complex numbers.
*
* \param[in] x Input matrix. Must be the starting address of a contiguous
* sequence of at least NumberOfElements() real numbers,
* stored in row order: all elements of the first row
* followed by all elements of the second row, and so on.
*
* \param[out] y Output matrix, where the result of the transform will be
* stored. Must be the starting address of a contiguous
* sequence of at least Rows()*(Cols()/2 + 1) complex
* numbers. The result will be stored in row order: all
* elements of the first row followed by all elements of the
* second row, and so on, where each row has Cols()/2 + 1
* complex numbers.
*
* The output matrix will have Rows() rows and Cols()/2 + 1 columns, stored
* in row order.
*
* This member function does not change the current Fourier transform in
* this object, if it exists.
*
* Returns a reference to this object.
*/
GenericRealFFT2D& operator()( complex* y, const scalar* x ) const
{
this->Transform( m_rows, m_cols, y, x, m_monitor, m_parallel, m_maxProcessors );
return const_cast<GenericRealFFT2D&>( *this );
}
/*!
* Performs the inverse two-dimensional %FFT of an input matrix of complex
* numbers, and stores the result in an output matrix of real numbers.
*
* \param[in] x Input matrix. Must be the starting address of a contiguous
* sequence of at least Rows()*(Cols()/2 + 1) complex
* numbers, stored in row order: all elements of the first
* row followed by all elements of the second row, and so on,
* where each row must have Cols()/2 + 1 complex numbers.
*
* \param[out] y Output matrix, where the result of the transform will be
* stored. Must be the starting address of a contiguous
* sequence of at least NumberOfElements() real numbers. The
* result will be stored in row order: all elements of the
* first row followed by all elements of the second row, and
* so on.
*
* The input matrix must have Rows() rows and Cols()/2 + 1 columns, stored
* in row order.
*
* This member function does not change the current Fourier transform in
* this object, if it exists.
*
* Returns a reference to this object.
*/
GenericRealFFT2D& operator()( scalar* y, const complex* x ) const
{
this->Transform( m_rows, m_cols, y, x, m_monitor, m_parallel, m_maxProcessors );
return const_cast<GenericRealFFT2D&>( *this );
}
/*!
* Returns the <em>optimized complex %FFT length</em> larger than or equal to
* a given length \a n. The returned length will be optimal to perform a
* %FFT of real data with the current PCL implementation. The optimized
* length can be used as the \a rows or \a cols argument to the constructor
* of any two-dimensional %FFT class for real-valued data transforms.
*/
static int OptimizedLength( int n )
{
return GenericFFT<T>::OptimizedLength( n );
}
};
// ----------------------------------------------------------------------------
#undef m_dft
#undef m_rows
#undef m_cols
#undef m_monitor
#undef m_parallel
#undef m_maxProcessors
// ----------------------------------------------------------------------------
/*!
* \defgroup fft_2d Two-Dimensional Fast Fourier Transforms
*/
#ifndef __PCL_NO_FFT2D_INSTANTIATE
/*!
* \class pcl::FFFT2D
* \ingroup fft_2d
* \brief Fast Fourier transform of 32-bit floating point complex data.
*
* %FFFT2D is a template instantiation of GenericFFT2D for the \c float type.
*/
typedef GenericFFT2D<float> FFFT2D;
/*!
* \class pcl::DFFT2D
* \ingroup fft_2d
* \brief Fast Fourier transform of 64-bit floating point complex data.
*
* %DFFT2D is a template instantiation of GenericFFT2D for the \c double type.
*/
typedef GenericFFT2D<double> DFFT2D;
/*!
* \class pcl::FRealFFT2D
* \ingroup fft_2d
* \brief Fast Fourier transform of 32-bit floating point real data.
*
* %FRealFFT2D is a template instantiation of GenericRealFFT2DT for \c float.
*/
typedef GenericRealFFT2D<float> FRealFFT2D;
/*!
* \class pcl::DRealFFT2D
* \ingroup fft_2d
* \brief Fast Fourier transform of 64-bit floating point real data.
*
* %DRealFFT2D is a template instantiation of GenericRealFFT2D for \c double.
*/
typedef GenericRealFFT2D<double> DRealFFT2D;
/*!
* \class pcl::FFT2D
* \ingroup fft_2d
* \brief Fast Fourier transform of 32-bit floating point complex data.
*
* %FFT2D is an alias for FFFT2D. It is a template instantiation of
* GenericFFT2D for the \c float type.
*/
typedef FFFT2D FFT2D;
/*!
* \class pcl::RealFFT2D
* \ingroup fft_2d
* \brief Fast Fourier transform of 32-bit floating point real data.
*
* %RealFFT2D is an alias for FRealFFT2D. It is a template instantiation of
* GenericRealFFT2D for the \c float type.
*/
typedef FRealFFT2D RealFFT2D;
#endif // __PCL_NO_FFT2D_INSTANTIATE
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_FFT2D_h
// ----------------------------------------------------------------------------
// EOF pcl/FFT2D.h - Released 2022-03-12T18:59:29Z
-477
View File
@@ -1,477 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/FFTConvolution.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_FFTConvolution_h
#define __PCL_FFTConvolution_h
/// \file pcl/FFTConvolution.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/AutoPointer.h>
#include <pcl/ImageTransformation.h>
#include <pcl/KernelFilter.h>
#include <pcl/ParallelProcess.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \defgroup convolution_speed_limits Helper Functions for Selection of
* Convolution Algorithms
*/
/*!
* \class FFTConvolution
* \brief Fourier-based two-dimensional convolution in the spatial domain
*
* %FFTConvolution implements a fully multithreaded, two-dimensional discrete
* convolution algorithm via fast Fourier transforms. It performs automatic
* fixing of border artifacts by applying Neumann boundary conditions
* (mirroring), and is able to convolve images and response functions of
* arbitrary sizes, only limited by the available memory.
*
* \sa Convolution, SeparableConvolution
*/
class PCL_CLASS FFTConvolution : public ImageTransformation, public ParallelProcess
{
public:
/*!
* Default constructor.
*
* \note This constructor yields an uninitialized instance that cannot be
* used before explicit association with a response function, specified
* either as a KernelFilter object or as an ImageVariant.
*/
FFTConvolution() = default;
/*!
* Constructs an %FFTConvolution instance with the specified kernel filter.
*
* \param filter Response function, or <em>convolution filter</em>. The
* specified object does not have to remain valid while this
* %FFTConvolution instance is actively used, since it owns a
* private copy of the filter (note that KernelFilter is a
* reference-counted class).
*/
FFTConvolution( const KernelFilter& filter )
: m_filter( filter.Clone() )
{
PCL_CHECK( bool( m_filter ) )
}
/*!
* Constructs an %FFTConvolution instance with the specified response
* function image.
*
* \param f A reference to an ImageVariant whose transported image is the
* <em>response function</em>, or <em>convolution filter</em>.
* The transported image <em>must remain valid</em> while this
* %FFTConvolution instance is actively used, or until a new
* response function is associated with this instance. The
* specified %ImageVariant doesn't have to remain valid, since a
* %FFTConvolution instance owns a private %ImageVariant that
* transports the response function image.
*/
FFTConvolution( const ImageVariant& f )
: m_image( f )
{
PCL_CHECK( bool( m_image ) )
}
/*!
* Copy constructor.
*/
FFTConvolution( const FFTConvolution& x )
: ImageTransformation( x )
, ParallelProcess( x )
, m_image( x.m_image )
, m_outputRealCmp( x.m_outputRealCmp )
{
if ( x.m_filter )
m_filter = x.m_filter->Clone();
}
/*!
* Move constructor.
*/
FFTConvolution( FFTConvolution&& ) = default;
/*!
* Destroys this %FFTConvolution object.
*/
virtual ~FFTConvolution()
{
}
/*!
* Copy assignment operator. Returns a reference to this object.
*/
FFTConvolution& operator =( const FFTConvolution& x )
{
if ( &x != this )
{
(void)ImageTransformation::operator =( x );
(void)ParallelProcess::operator =( x );
DestroyFilter();
if ( x.m_filter )
m_filter = x.m_filter->Clone();
else
m_image = x.m_image;
m_outputRealCmp = x.m_outputRealCmp;
}
return *this;
}
/*!
* Move assignment operator. Returns a reference to this object.
*/
FFTConvolution& operator =( FFTConvolution&& ) = default;
/*!
* Returns true if this %FFTConvolution uses a KernelFilter object as its
* response function; false if it uses an image.
*/
bool UsingFilter() const
{
return m_filter;
}
/*!
* Returns a reference to the kernel filter currently associated with this
* %FFTConvolution object. If this object does not use a kernel filter,
* either because it uses an image as its response function, or because this
* object has not been initialized, the returned filter is empty (i.e., it
* has no filter coefficients and zero dimensions).
*/
const KernelFilter& Filter() const
{
PCL_PRECONDITION( bool( m_filter ) )
return *m_filter;
}
/*!
* Returns a reference to the filter image currently associated with this
* %FFTConvolution object. The referenced ImageVariant object will transport
* no image if this object does not use a filter image, either because it
* uses a kernel filter as its response function, or because this object has
* not been initialized.
*
* The response function is actually the image transported by the returned
* ImageVariant. It can be an image of any supported data type.
*/
const ImageVariant& FilterImage() const
{
return m_image;
}
/*!
* Sets a new kernel filter as the response function to be applied by this
* %FFTConvolution object.
*
* The specified object does not have to remain valid while this
* %FFTConvolution instance is actively used, since it owns a private copy
* of the filter (note that KernelFilter is a reference-counted class).
*/
void SetFilter( const KernelFilter& filter )
{
DestroyFilter();
m_filter = filter.Clone();
PCL_CHECK( bool( m_filter ) )
}
/*!
* Sets a new filter image as the response function to be applied by this
* %FFTConvolution object.
*
* The image transported by the specified ImageVariant must remain valid
* while this %FFTConvolution instance is actively used, or until a new
* response function is associated with this instance. The %ImageVariant
* doesn't have to remain valid, since this object owns a private
* %ImageVariant that transports the response function image.
*/
void SetFilter( const ImageVariant& filter )
{
DestroyFilter();
m_image = filter;
PCL_CHECK( bool( m_image ) )
}
/*!
* Returns a pointer to the discrete Fourier transform (DFT) of the
* complex <em>response function</em> used internally by this
* %FFTConvolution object, or nullptr if the response function has not been
* created yet.
*
* The internal DFT of the response function is created and initialized the
* first time this %FFTConvolution object is used to perform a convolution.
* It is reused to save memory and CPU resources, as long as successive
* transformations apply to target images with the same dimensions, or
* otherwise it is re-created on the fly, as necessary. It is destroyed when
* a new filter is associated with this object.
*
* This function returns a pointer to a complex image that stores the DFT
* of the original filter after transforming it to <em>wrap around
* order</em>. This means that the original filter data has been splitted,
* mirrored, and redistributed to occupy the four corners of the complex 2-D
* matrix prior to calculating its DFT.
*
* If this object has not been initialized, the returned pointer is nullptr.
*/
const ComplexImage* ResponseFunctionDFT() const
{
return m_h;
}
/*!
* Returns true if this object applies to real images by copying the real
* component of the complex convolved result.
*
* Returns false if this object applies to real images by storing the
* magnitude of the complex convolution result. This is the default
* behavior.
*
* \sa IsMagnitudeOutputEnabled(), EnableRealComponentOutput()
*/
bool IsRealComponentOutputEnabled() const
{
return m_outputRealCmp;
}
/*!
* Returns true if this object applies to real images by storing the
* magnitude of the complex convolution result. This is the default
* behavior.
*
* Returns false if this object applies to real images by copying the real
* component of the complex convolved result.
*
* \sa IsRealComponentOutputEnabled(), EnableMagnitudeOutput()
*/
bool IsMagnitudeOutputEnabled() const
{
return !m_outputRealCmp;
}
/*!
* Causes this object to apply to real images by copying the real component
* of the complex convolved result.
*
* \sa IsRealComponentOutputEnabled(), EnableMagnitudeOutput()
*/
void EnableRealComponentOutput( bool enable = true )
{
m_outputRealCmp = enable;
}
/*!
* Causes this object to apply to real images by storing the magnitude of
* the complex convolution result. This is the default behavior.
*
* \sa IsMagnitudeOutputEnabled(), EnableRealComponentOutput()
*/
void EnableMagnitudeOutput( bool enable = true )
{
m_outputRealCmp = !enable;
}
/*!
* Returns the minimum filter size in pixels for which FFT-based
* two-dimensional convolution is consistently faster than nonseparable
* convolution on the current PixInsight/PCL platform, for the specified
* number of parallel execution threads.
*
* The values returned by this function have been determined experimentally
* on reference hardware for optimized execution on machines and builds with
* and without AVX2/FMA3 processor instruction support.
*
* \ingroup convolution_speed_limits
*/
static constexpr int FasterThanNonseparableFilterSize( int numThreads )
{
#ifdef __PCL_COMPATIBILITY
// No vectorization
if ( numThreads >= 32 )
return 17;
if ( numThreads >= 24 )
return 15;
if ( numThreads >= 12 )
return 13;
if ( numThreads >= 8 )
return 11;
return 9;
#else
// Vectorization with SSE4.2 / AVX2 and FMA instructions
if ( numThreads >= 32 )
return 29;
if ( numThreads >= 24 )
return 27;
if ( numThreads >= 16 )
return 25;
if ( numThreads >= 12 )
return 21;
if ( numThreads >= 8 )
return 19;
if ( numThreads >= 4 )
return 17;
if ( numThreads >= 2 )
return 15;
return 13;
#endif
}
/*!
* Returns the minimum filter size in pixels for which FFT-based
* two-dimensional convolution is consistently faster than separable
* convolution on the current PixInsight/PCL platform, for the specified
* number of parallel execution threads.
*
* The values returned by this function have been determined experimentally
* on reference hardware for optimized execution on machines and builds with
* and without AVX2/FMA3 processor instruction support.
*
* \ingroup convolution_speed_limits
*/
static constexpr int FasterThanSeparableFilterSize( int numThreads )
{
#ifdef __PCL_COMPATIBILITY
// No vectorization
if ( numThreads >= 24 )
return 191;
if ( numThreads >= 16 )
return 141;
if ( numThreads >= 12 )
return 135;
if ( numThreads >= 8 )
return 95;
if ( numThreads >= 4 )
return 75;
return 61;
#else
// Vectorization with SSE4.2 / AVX2 and FMA instructions
if ( numThreads >= 16 )
return 901;
if ( numThreads >= 12 )
return 831;
if ( numThreads >= 8 )
return 741;
return 395;
#endif
}
protected:
/*
* The response function for convolution is defined as either a KernelFilter
* instance or as an image. In the latter case, the image transported by the
* ImageVariant must remain valid while this object is actively used.
*/
AutoPointer<KernelFilter> m_filter;
ImageVariant m_image;
bool m_outputRealCmp = false;
/*
* Internal DFT of the response function. Initially zero. This matrix is
* generated/reused/regenerated as this object is applied to convolve
* different target images. It is destroyed when a new filter is specified.
*/
mutable AutoPointer<ComplexImage> m_h;
/*
* In-place Fourier-based 2-D convolution algorithm.
*/
void Apply( pcl::Image& ) const override;
void Apply( pcl::DImage& ) const override;
void Apply( pcl::UInt8Image& ) const override;
void Apply( pcl::UInt16Image& ) const override;
void Apply( pcl::UInt32Image& ) const override;
void Apply( pcl::ComplexImage& ) const override;
void Apply( pcl::DComplexImage& ) const override;
friend class PCL_FFTConvolutionEngine;
private:
void DestroyFilter()
{
m_filter.Destroy();
m_image.Free();
m_h.Destroy();
}
void Validate() const;
void ValidateFilter() const;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_FFTConvolution_h
// ----------------------------------------------------------------------------
// EOF pcl/FFTConvolution.h - Released 2022-03-12T18:59:29Z
-611
View File
@@ -1,611 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/FFTRegistration.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_FFTRegistration_h
#define __PCL_FFTRegistration_h
/// \file pcl/FFTRegistration.h
#include <pcl/Defs.h>
#include <pcl/ImageVariant.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class FFTRegistrationEngine
* \brief Base class of %FFT-based image registration algorithms
*
* Image registration based on phase correlation via fast Fourier transforms.
*
* <b>References</b>
*
* \li Araiza, R., Xie, H. & al., 2002. Automatic referencing of multi-spectral
* images. Proceedings of 15th IEEE Southwest Symposium on Image Analysis and
* Interpretation, Santa Fe, USA, 21-25.
*
* \li Xie, H. & al., 2000. Automatic image registration based on a %FFT
* algorithm and IDL/ENVI. Proceedings of the ICORG-2000 International
* Conference on Remote Sensing and GIS/GPS, Hyderabad, India, I-397~I-402.
*
* \li Harold S., Stone T. & al., 2003. Analysis of image registration noise
* due to rotationally dependent aliasing. Journal of Visual Communication and
* Image Representation 14, 114-135.
*
* \li DeCastro, E., Morandi, C., 1987. Registration of translated and rotated
* images using finite Fourier transforms. IEEE Transactions on Pattern
* Analysis and Machine Intelligence 95, 700-703.
*/
class PCL_CLASS FFTRegistrationEngine
{
public:
/*!
* Constructs an %FFTRegistrationEngine object.
*/
FFTRegistrationEngine() = default;
/*!
* Copy constructor.
*/
FFTRegistrationEngine( const FFTRegistrationEngine& ) = default;
/*!
* Move constructor.
*/
FFTRegistrationEngine( FFTRegistrationEngine&& x )
: m_fftReference( std::move( x.m_fftReference ) )
{
}
/*!
* Destroys an %FFTRegistrationEngine object.
*/
virtual ~FFTRegistrationEngine()
{
}
/*!
* Returns true iff this engine has been initialized.
*/
bool IsInitialized() const
{
return !m_fftReference.IsEmpty();
}
/*!
* Initializes this registration engine for the specified reference image
* \a image.
*
* Once initialized, subsequent calls to Evaluate() will compute
* registration parameters for target images referred to the same reference
* image, until a new initialization is performed, or until the Reset()
* member function is called.
*/
template <class P>
void Initialize( const pcl::GenericImage<P>& image )
{
Reset();
m_fftReference = DoInitialize( image );
}
/*!
* Initializes this registration engine for the specified reference
* \a image.
*
* This member function behaves like Initialize( const GenericImage<P>& ),
* except that it receives a reference to ImageVariant. The engine is
* initialized for the image transported by the ImageVariant object.
*/
void Initialize( const ImageVariant& image )
{
Reset();
if ( image )
if ( image.IsComplexSample() )
switch ( image.BitsPerSample() )
{
case 32: m_fftReference = DoInitialize( static_cast<const ComplexImage&>( *image ) ); break;
case 64: m_fftReference = DoInitialize( static_cast<const DComplexImage&>( *image ) ); break;
}
else if ( image.IsFloatSample() )
switch ( image.BitsPerSample() )
{
case 32: m_fftReference = DoInitialize( static_cast<const Image&>( *image ) ); break;
case 64: m_fftReference = DoInitialize( static_cast<const DImage&>( *image ) ); break;
}
else
switch ( image.BitsPerSample() )
{
case 8: m_fftReference = DoInitialize( static_cast<const UInt8Image&>( *image ) ); break;
case 16: m_fftReference = DoInitialize( static_cast<const UInt16Image&>( *image ) ); break;
case 32: m_fftReference = DoInitialize( static_cast<const UInt32Image&>( *image ) ); break;
}
}
/*!
* Returns a reference to the discrete Fourier transform of the reference
* image.
*
* The reference image is the image specified in the last call to
* Initialize(). This function returns an empty image if this registration
* engine has not been initialized.
*/
const ComplexImage& DFTOfReferenceImage() const
{
return m_fftReference;
}
/*!
* Resets this registration engine and deallocates all internal data
* structures. The engine will have to be initialized before performing new
* evaluations of registration parameters.
*/
void Reset()
{
m_fftReference.FreeData();
}
/*!
* Evaluates a target image \a image to compute registration parameters.
*
* Before calling this function, the engina must be initialized by calling
* Initialize() with a reference image.
*/
template <class P>
void Evaluate( const pcl::GenericImage<P>& image )
{
PCL_PRECONDITION( IsInitialized() )
if ( IsInitialized() )
DoEvaluate( image );
}
/*!
* Evaluates a target image \a vimg to compute registration parameters.
*
* This member function behaves like Evaluate( const GenericImage<P>& ),
* except that it receives a reference to ImageVariant. The engine evaluates
* for the image transported by the ImageVariant object.
*/
void Evaluate( const ImageVariant& image )
{
PCL_PRECONDITION( IsInitialized() )
if ( IsInitialized() )
if ( image )
if ( image.IsComplexSample() )
switch ( image.BitsPerSample() )
{
case 32: DoEvaluate( static_cast<const pcl::ComplexImage&>( *image ) ); break;
case 64: DoEvaluate( static_cast<const pcl::DComplexImage&>( *image ) ); break;
}
else if ( image.IsFloatSample() )
switch ( image.BitsPerSample() )
{
case 32: DoEvaluate( static_cast<const pcl::Image&>( *image ) ); break;
case 64: DoEvaluate( static_cast<const pcl::DImage&>( *image ) ); break;
}
else
switch ( image.BitsPerSample() )
{
case 8: DoEvaluate( static_cast<const pcl::UInt8Image&>( *image ) ); break;
case 16: DoEvaluate( static_cast<const pcl::UInt16Image&>( *image ) ); break;
case 32: DoEvaluate( static_cast<const pcl::UInt32Image&>( *image ) ); break;
}
}
protected:
// DFT of the reference image.
ComplexImage m_fftReference;
virtual ComplexImage DoInitialize( const pcl::Image& ) = 0;
virtual ComplexImage DoInitialize( const pcl::DImage& ) = 0;
virtual ComplexImage DoInitialize( const pcl::ComplexImage& ) = 0;
virtual ComplexImage DoInitialize( const pcl::DComplexImage& ) = 0;
virtual ComplexImage DoInitialize( const pcl::UInt8Image& ) = 0;
virtual ComplexImage DoInitialize( const pcl::UInt16Image& ) = 0;
virtual ComplexImage DoInitialize( const pcl::UInt32Image& ) = 0;
virtual void DoEvaluate( const pcl::Image& ) = 0;
virtual void DoEvaluate( const pcl::DImage& ) = 0;
virtual void DoEvaluate( const pcl::ComplexImage& ) = 0;
virtual void DoEvaluate( const pcl::DComplexImage& ) = 0;
virtual void DoEvaluate( const pcl::UInt8Image& ) = 0;
virtual void DoEvaluate( const pcl::UInt16Image& ) = 0;
virtual void DoEvaluate( const pcl::UInt32Image& ) = 0;
};
// ----------------------------------------------------------------------------
/*!
* \defgroup fft_registration_functions FFT-Based Registration Operators
*/
/*!
* Initializes a %FFT registration engine or evaluates a target image.
*
* \param R %FFT registration engine.
* \param image An image or ImageVariant for initialization or evaluation.
*
* If the engine has not still been initialized, it is initialized for the
* \e reference image \a image. Once the engine has been initialized, it
* evaluates registration parameters for the specified \e target image \a image.
*
* Returns a reference to the %FFT registration engine \a R.
*
* \sa FFTRegistrationEngine
*
* \ingroup fft_registration_functions
*/
template <class O> inline
FFTRegistrationEngine& operator <<( FFTRegistrationEngine& R, const O& image )
{
if ( !R.IsInitialized() )
R.Initialize( image );
else
R.Evaluate( image );
return R;
}
// ----------------------------------------------------------------------------
/*!
* \class FFTTranslation
* \brief %FFT registration engine: translation
*
* %FFTTranslation evaluates translation image registration parameters. It
* computes the offsets \e dx and \e dy required to register a target image on
* a reference image, using an %FFT-based phase correlation algorithm.
*
* \sa FFTRotationAndScaling, FFTRegistrationEngine
*/
class PCL_CLASS FFTTranslation : public FFTRegistrationEngine
{
public:
/*!
* Constructs an %FFTTranslation object.
*/
FFTTranslation() = default;
/*!
* Destroys an %FFTTranslation object.
*/
virtual ~FFTTranslation()
{
}
/*!
* Returns true iff this registration engine can evaluate translations
* greater than or equal to one half of the largest dimension of the
* reference image.
*
* \sa EnableLargeTranslations(), DisableLargeTranslations()
*/
bool AreLargeTranslationsEnabled() const
{
return m_largeTranslations;
}
/*!
* Enables or disables evaluation of large translations (>= one half of the
* reference image dimension).
*
* \warning When large translations are enabled, the engine needs to double
* the sizes of internal working matrices, which \e quadruplicates the
* amount of required memory.
*
* \sa DisableLargeTranslations(), AreLargeTranslationsEnabled()
*/
void EnableLargeTranslations( bool enable = true )
{
if ( enable != m_largeTranslations )
{
Reset();
m_largeTranslations = enable;
}
}
/*!
* Disables or enables evaluation of large translations (>= one half of the
* reference image dimension).
*
* This is a convenience member function, equivalent to
* EnableLargeTranslations( !disable )
*
* \warning When large translations are enabled, the engine needs to double
* the sizes of internal working matrices, which \e quadruplicates the
* amount of required memory.
*
* \sa EnableLargeTranslations(), AreLargeTranslationsEnabled()
*/
void DisableLargeTranslations( bool disable = true )
{
EnableLargeTranslations( !disable );
}
/*!
* Returns the evaluated translation increments in pixels.
*
* The returned Point object contains the required offsets in the X and Y
* directions to register the last evaluated target image on the reference
* image set upon initialization.
*
* \sa DeltaX(), DeltaY()
*/
const FPoint& Delta() const
{
return m_delta;
}
/*!
* Returns the evaluated translation increment in the X direction, in
* pixels.
*
* \sa DeltaY(), Delta()
*/
float DeltaX() const
{
return m_delta.x;
}
/*!
* Returns the evaluated translation increment in the Y direction, in
* pixels.
*
* \sa DeltaX(), Delta()
*/
float DeltaY() const
{
return m_delta.y;
}
/*!
* Returns the peak value read from the phase matrix for the last evaluated
* target image. The peak value isn't normalized, that is, it doesn't
* necessarily have to be in the [0,1] range.
*/
float Peak() const
{
return m_peak;
}
protected:
// Allow translations > size/2.
// Warning: a lot of memory may be necessary --four times more.
bool m_largeTranslations = false;
// Evaluation result.
FPoint m_delta = 0.0F;
// Peak value detected in the phase matrix.
float m_peak = 0.0F;
ComplexImage DoInitialize( const pcl::Image& ) override;
ComplexImage DoInitialize( const pcl::DImage& ) override;
ComplexImage DoInitialize( const pcl::ComplexImage& ) override;
ComplexImage DoInitialize( const pcl::DComplexImage& ) override;
ComplexImage DoInitialize( const pcl::UInt8Image& ) override;
ComplexImage DoInitialize( const pcl::UInt16Image& ) override;
ComplexImage DoInitialize( const pcl::UInt32Image& ) override;
void DoEvaluate( const pcl::Image& ) override;
void DoEvaluate( const pcl::DImage& ) override;
void DoEvaluate( const pcl::ComplexImage& ) override;
void DoEvaluate( const pcl::DComplexImage& ) override;
void DoEvaluate( const pcl::UInt8Image& ) override;
void DoEvaluate( const pcl::UInt16Image& ) override;
void DoEvaluate( const pcl::UInt32Image& ) override;
};
// ----------------------------------------------------------------------------
/*!
* \class FFTRotationAndScaling
* \brief %FFT registration engine: rotation and scaling
*
* %FFTRotationAndScaling evaluates rotation and scaling image registration
* parameters. It computes the rotation angle and scaling ratio required to
* register a target image on a reference image, using an algorithm based on
* the Fourier-Mellin transform.
*
* \warning This class is currently experimental. It is not guaranteed to
* provide reliable image registration parameters.
*
* \sa FFTTranslation, FFTRegistrationEngine
*/
class PCL_CLASS FFTRotationAndScaling : public FFTRegistrationEngine
{
public:
/*!
* Constructs a %FFTRotationAndScaling object.
*
* Scaling ratio evaluation (see EvaluatesScaling()) is disabled by default.
*/
FFTRotationAndScaling() = default;
/*!
* Destroys a %FFTRotationAndScaling object.
*/
virtual ~FFTRotationAndScaling()
{
}
/*!
* Returns true iff this engine evaluates scaling ratios. By default, scale
* evaluation is disabled.
*/
bool EvaluatesScaling() const
{
return m_evaluateScaling;
}
/*!
* Enables evaluation of scaling ratios.
*/
void EnableScalingEvaluation( bool enable = true )
{
if ( enable != m_evaluateScaling )
{
Reset();
m_evaluateScaling = enable;
}
}
/*!
* Disables evaluation of scaling ratios.
*
* This is a convenience member function, equivalent to
* EnableScalingEvaluation( !disable )
*/
void DisableScalingEvaluation( bool disable = true )
{
EnableScalingEvaluation( !disable );
}
/*!
* Returns the current low frequency cutoff for this registration engine.
*
* See the documentation for SetLowFrequencyCutoff() for a detailed
* description of low-frequency cutoffs.
*/
float LowFrequencyCutoff() const
{
return m_lowFrequencyCutoff;
}
/*!
* Returns true iff this engine uses a low-frequency cutoff to reduce the
* effects of rotational aliasing.
*/
bool HasLowFrequencyCutoff() const
{
return LowFrequencyCutoff() > 0;
}
/*!
* Sets the radius of the low-frequency cutoff.
*
* The evaluation of rotation and scaling registration parameters can
* benefit from a simple low-frequency cutoff operation to reduce rotational
* aliasing on the computed DFTs. The value set by this function is the
* radius of the cutoff \e hole relative to the largest dimension of the
* reference image. The default value is 1/200. A value of zero disables the
* low-frequency cutoff feature.
*/
void SetLowFrequencyCutoff( float r )
{
m_lowFrequencyCutoff = Range( r, 0.0F, 0.5F );
}
/*!
* Returns the evaluated rotation angle in radians.
*
* The returned value is the required rotation angle to register the last
* evaluated target image on the reference image set upon initialization.
*/
float RotationAngle() const
{
return m_rotationAngle;
}
/*!
* Returns the evaluated scaling ratio.
*
* The returned value is the required scaling ratio to register the last
* evaluated target image on the reference image set upon initialization.
*/
float ScalingRatio() const
{
return m_scalingRatio;
}
protected:
// Evaluate rotation+scaling, or just rotation?
bool m_evaluateScaling = false;
// Low-frequency cutoff, as a fraction of the DFT radius.
float m_lowFrequencyCutoff = 1.0F/200;
// Evaluation result
float m_rotationAngle = 0.0F; // radians
float m_scalingRatio = 1.0F; // pixels
ComplexImage DoInitialize( const pcl::Image& ) override;
ComplexImage DoInitialize( const pcl::DImage& ) override;
ComplexImage DoInitialize( const pcl::ComplexImage& ) override;
ComplexImage DoInitialize( const pcl::DComplexImage& ) override;
ComplexImage DoInitialize( const pcl::UInt8Image& ) override;
ComplexImage DoInitialize( const pcl::UInt16Image& ) override;
ComplexImage DoInitialize( const pcl::UInt32Image& ) override;
void DoEvaluate( const pcl::Image& ) override;
void DoEvaluate( const pcl::DImage& ) override;
void DoEvaluate( const pcl::ComplexImage& ) override;
void DoEvaluate( const pcl::DComplexImage& ) override;
void DoEvaluate( const pcl::UInt8Image& ) override;
void DoEvaluate( const pcl::UInt16Image& ) override;
void DoEvaluate( const pcl::UInt32Image& ) override;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_FFTRegistration_h
// ----------------------------------------------------------------------------
// EOF pcl/FFTRegistration.h - Released 2022-03-12T18:59:29Z
-290
View File
@@ -1,290 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/FITSHeaderKeyword.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_FITSHeaderKeyword_h
#define __PCL_FITSHeaderKeyword_h
/// \file pcl/FITSHeaderKeyword.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/Array.h>
#include <pcl/String.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class FITSHeaderKeyword
* \brief %FITS header keyword
*/
class PCL_CLASS FITSHeaderKeyword
{
public:
IsoString name; //!< Keyword name
IsoString value; //!< Keyword value
IsoString comment; //!< Keyword comment
/*!
* Constructs a %FITSHeaderKeyword object with empty name, value and comment
* components.
*/
FITSHeaderKeyword() = default;
/*!
* Copy constructor.
*/
FITSHeaderKeyword( const FITSHeaderKeyword& ) = default;
/*!
* Move constructor.
*/
FITSHeaderKeyword( FITSHeaderKeyword&& ) = default;
/*!
* Constructs a %FITSHeaderKeyword object with the specified name, value and
* comment components.
*/
FITSHeaderKeyword( const IsoString& a_name,
const IsoString& a_value = IsoString(),
const IsoString& a_comment = IsoString() )
: name( a_name )
, value( a_value )
, comment( a_comment )
{
Trim();
}
template <class S1, class S2, class S3>
FITSHeaderKeyword( const S1& a_name, const S2& a_value, const S3& a_comment )
: name( IsoString( a_name ) )
, value( IsoString( a_value ) )
, comment( IsoString( a_comment ) )
{
Trim();
}
/*!
* Assignment operator. Returns a reference to this object.
*/
FITSHeaderKeyword& operator =( const FITSHeaderKeyword& ) = default;
/*!
* Returns true iff this %FITS keyword has no %value (i.e., if the value
* member is an empty string).
*/
bool IsNull() const
{
return value.IsEmpty();
}
/*!
* Returns true iff this %FITS keyword has a string %value.
*
* A string %value is assumed if the value component begins with a single
* quote (').
*/
bool IsString() const
{
return value.StartsWith( '\'' );
}
/*!
* Returns true iff this %FITS keyword has a boolean %value.
*
* A boolean %value is assumed if the value component is equal to 'T' or 'F'
* for \c true and \c false, respectively.
*/
bool IsBoolean() const
{
return value == 'T' || value == 'F';
}
/*!
* Returns true iff this %FITS keyword has a numeric %value.
*
* A numeric %value is assumed if the value component is a valid
* representation of an integer or floating point number.
*/
bool IsNumeric() const
{
return value.IsNumeral();
}
/*!
* Gets the numeric %value of this %FITS keyword in the specified variable
* \a v, or zero if this keyword has no numeric %value.
*
* Returns true iff this keyword has a valid numeric %value. This member
* function does not throw exceptions, even if the keyword's value contains
* an illegal numeric representation.
*/
bool GetNumericValue( double& v ) const
{
if ( value.TryToDouble( v ) )
return true;
v = 0;
return false;
}
/*!
* Returns the string %value of this %FITS header keyword (irrespective of
* its data type), with delimiters pulled off and leading/trailing
* whitespace trimmed out.
*/
IsoString StripValueDelimiters() const
{
IsoString stripped;
if ( !value.IsEmpty() && *value == '\'' ) // leading delimiter ?
{
size_type n = value.Length()-1;
if ( value[n] == '\'' ) // trailing delimiter ?
--n;
stripped = value.Substring( 1, n );
}
else
stripped = value;
return stripped.Trimmed();
}
/*!
* If this keyword has a string value without leading and trailing quotes,
* this member function adds them, as required by the FITS standard. Returns
* true if the value was fixed, false if the value was not changed.
*/
bool FixValueDelimiters()
{
double dum;
if ( !IsNull() )
if ( !IsString() )
if ( !IsBoolean() )
if ( !IsNumeric() || !value.TryToDouble( dum ) )
{
value.EnsureSingleQuoted();
return true;
}
return false;
}
/*!
* Removes leading and trailing spaces in the name, value and comment
* components of this %FITS header keyword.
*/
void Trim()
{
name.Trim();
value.Trim();
comment.Trim();
}
};
// ----------------------------------------------------------------------------
/*!
* \class pcl::FITSKeywordArray
* \brief Dynamic array of %FITS header keywords
*
* %FITSKeywordArray is a template instantiation of Array for
* FITSHeaderKeyword.
*/
typedef Array<FITSHeaderKeyword> FITSKeywordArray;
// ----------------------------------------------------------------------------
/*!
* \defgroup fits_keyword_comparison FITS Keyword Comparison Functions
*/
/*!
* Returns true iff two %FITS header keywords, \a h1 and \a h2, are equal.
*
* Two %FITS keywords are equal if their three components (name, value,
* comment) are equal. However, keyword name comparison is case-insensitive as
* per the %FITS standard.
*
* \ingroup fits_keyword_comparison
*/
inline bool operator ==( const FITSHeaderKeyword& h1, const FITSHeaderKeyword& h2 )
{
// Keyword name comparison is case-insensitive as per the FITS standard.
return h1.name.CompareIC( h2.name ) == 0 && h1.value == h2.value && h1.comment == h2.comment;
}
/*!
* Returns true iff a %FITS header keyword \a h1 is less than other keyword
* \a h2.
*
* This function compares the components of both keywords. The precedence order
* is name, value and comment. Keyword name comparison is case-insensitive as
* per the %FITS standard.
*
* \ingroup fits_keyword_comparison
*/
inline bool operator <( const FITSHeaderKeyword& h1, const FITSHeaderKeyword& h2 )
{
int i = h1.name.CompareIC( h2.name );
return i < 0 || i == 0 && (h1.value < h2.value || h1.value == h2.value && h1.comment < h2.comment);
}
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_FITSHeaderKeyword_h
// ----------------------------------------------------------------------------
// EOF pcl/FITSHeaderKeyword.h - Released 2022-03-12T18:59:29Z
-241
View File
@@ -1,241 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/FastRotation.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_FastRotation_h
#define __PCL_FastRotation_h
/// \file pcl/FastRotation.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/GeometricTransformation.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \defgroup fast_rotations Non-interpolating Rotations and Specular&nbsp;\
* Transformations.
*
* <em>Fast rotations</em> are non-interpolating geometric transformations:
* they carry out image rotation and specular projection operations exclusively
* by copying and swapping pixels.
*
* Since no pixel interpolation is performed, there is absolutely no data
* degradation after an arbitrary number of consecutive fast rotations.
*/
// ----------------------------------------------------------------------------
/*!
* \class Rotate180
* \brief Rotates images by 180 degrees
*
* \ingroup fast_rotations
*/
class PCL_CLASS Rotate180 : public GeometricTransformation
{
public:
/*!
*/
void GetNewSizes( int& w, int& h ) const override
{
// No change
}
protected:
// Inherited from ImageTransformation.
void Apply( pcl::Image& ) const override;
void Apply( pcl::DImage& ) const override;
void Apply( pcl::ComplexImage& ) const override;
void Apply( pcl::DComplexImage& ) const override;
void Apply( pcl::UInt8Image& ) const override;
void Apply( pcl::UInt16Image& ) const override;
void Apply( pcl::UInt32Image& ) const override;
};
// ----------------------------------------------------------------------------
/*!
* \class Rotate90CW
* \brief Rotates images by 90 degrees (clockwise)
*
* \ingroup fast_rotations
*/
class PCL_CLASS Rotate90CW : public GeometricTransformation
{
public:
/*!
*/
void GetNewSizes( int& w, int& h ) const override
{
pcl::Swap( w, h ); // Permute
}
protected:
// Inherited from ImageTransformation.
void Apply( pcl::Image& ) const override;
void Apply( pcl::DImage& ) const override;
void Apply( pcl::ComplexImage& ) const override;
void Apply( pcl::DComplexImage& ) const override;
void Apply( pcl::UInt8Image& ) const override;
void Apply( pcl::UInt16Image& ) const override;
void Apply( pcl::UInt32Image& ) const override;
};
// ----------------------------------------------------------------------------
/*!
* \class Rotate90CCW
* \brief Rotates images by -90 degrees (counter-clockwise)
*
* \ingroup fast_rotations
*/
class PCL_CLASS Rotate90CCW : public GeometricTransformation
{
public:
/*!
*/
void GetNewSizes( int& w, int& h ) const override
{
pcl::Swap( w, h ); // Permute
}
protected:
// Inherited from ImageTransformation.
void Apply( pcl::Image& ) const override;
void Apply( pcl::DImage& ) const override;
void Apply( pcl::ComplexImage& ) const override;
void Apply( pcl::DComplexImage& ) const override;
void Apply( pcl::UInt8Image& ) const override;
void Apply( pcl::UInt16Image& ) const override;
void Apply( pcl::UInt32Image& ) const override;
};
// ----------------------------------------------------------------------------
/*!
* \class HorizontalMirror
* \brief Mirrors images horizontally
*
* \ingroup fast_rotations
*/
class PCL_CLASS HorizontalMirror : public GeometricTransformation
{
public:
/*!
*/
void GetNewSizes( int& w, int& h ) const override
{
// No change
}
protected:
// Inherited from ImageTransformation.
void Apply( pcl::Image& ) const override;
void Apply( pcl::DImage& ) const override;
void Apply( pcl::ComplexImage& ) const override;
void Apply( pcl::DComplexImage& ) const override;
void Apply( pcl::UInt8Image& ) const override;
void Apply( pcl::UInt16Image& ) const override;
void Apply( pcl::UInt32Image& ) const override;
};
// ----------------------------------------------------------------------------
/*!
* \class VerticalMirror
* \brief Mirrors images vertically
*
* \ingroup fast_rotations
*/
class PCL_CLASS VerticalMirror : public GeometricTransformation
{
public:
/*!
*/
void GetNewSizes( int& w, int& h ) const override
{
// No change
}
protected:
// Inherited from ImageTransformation.
void Apply( pcl::Image& ) const override;
void Apply( pcl::DImage& ) const override;
void Apply( pcl::ComplexImage& ) const override;
void Apply( pcl::DComplexImage& ) const override;
void Apply( pcl::UInt8Image& ) const override;
void Apply( pcl::UInt16Image& ) const override;
void Apply( pcl::UInt32Image& ) const override;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_FastRotation_h
// ----------------------------------------------------------------------------
// EOF pcl/FastRotation.h - Released 2022-03-12T18:59:29Z
-2415
View File
File diff suppressed because it is too large Load Diff
-549
View File
@@ -1,549 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/FileDataCache.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_FileDataCache_h
#define __PCL_FileDataCache_h
/// \file pcl/FileDataCache.h
#include <pcl/File.h>
#include <pcl/Matrix.h>
#include <pcl/MultiVector.h>
#include <pcl/Mutex.h>
#include <pcl/ReferenceSortedArray.h>
#include <pcl/StringList.h>
#include <pcl/TimePoint.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class FileDataCacheItem
* \brief Element of a file data cache
*
* This class represents a file in a FileDataCache object. This is a basic
* cache item structure to transport a full file path and, the known time of
* last file modification, and the time of last cache access.
*/
class PCL_CLASS FileDataCacheItem
{
public:
String path; //!< Full path to the file represented by this item.
TimePoint time; //!< Cached file time.
TimePoint lastUsed; //!< Time this cache item was last used.
/*!
* Virtual destructor.
*/
virtual ~FileDataCacheItem()
{
}
/*!
* Assigns data from another cache \a item.
*/
void Assign( const FileDataCacheItem& item )
{
path = item.path;
time = item.time;
lastUsed = item.lastUsed;
}
/*!
* Returs true iff this object represents the same file as another cache
* \a item.
*/
bool operator ==( const FileDataCacheItem& item ) const
{
return path == item.path;
}
/*!
* Returns true iff this object precedes another cache \a item. File cache
* items are sorted by full file paths in ascending order.
*/
bool operator <( const FileDataCacheItem& item ) const
{
return path < item.path;
}
/*!
* Returns true iff the file represented by this cache item was last
* modified before the specified file time \a t.
*
* \note This member function ignores the milliseconds component of the
* specified FileTime instance, by setting it to zero. This is done to
* prevent wrong cache invalidations caused by unreliable file time
* milliseconds on Windows.
*/
bool ModifiedSince( FileTime t ) const
{
t.milliseconds = 0;
return time < TimePoint( t );
}
/*!
* Returns the amount of days elapsed since the time this cache item was
* last used.
*/
double DaysSinceLastUsed() const
{
return TimePoint::Now() - lastUsed;
}
protected:
/*!
* Assigns additional data stored in another file cache item.
*
* The default implementation does nothing. This virtual member function
* should be reimplemented by derived classes to ensure persistence of
* reimplementation-specific data.
*/
virtual void AssignData( const FileDataCacheItem& )
{
}
/*!
* Returns a string representation of additional data stored in this cache
* item.
*
* The default implementation returns an empty string. This virtual member
* function should be reimplemented by derived classes to allow access to
* reimplementation-specific data.
*/
virtual String DataToString() const
{
return String();
}
/*!
* Retrieves additional data from a list of string tokens. Returns true iff
* the data were successfully retrieved.
*
* The default implementation returns true. This virtual member function
* should be reimplemented by derived classes for retrieval of
* reimplementation-specific data.
*/
virtual bool GetDataFromTokens( const StringList& )
{
return true;
}
/*!
* Returns true iff the additional data stored in this cache item are valid.
*
* The default implementation returns true. This virtual member function
* should be reimplemented by derived classes for validation of
* reimplementation-specific data.
*/
virtual bool ValidateData() const
{
return true;
}
/*!
* Returns a string serialization of a floating-point vector. The returned
* string can be deserialized with the GetVector() static member function.
*/
static String VectorToString( const DVector& );
/*!
* Deserializes a floating-point vector from the specified list of
* \a tokens, parsing the necessary tokens starting from the specified
* \a start iterator.
*/
static bool GetVector( DVector&, StringList::const_iterator& start, const StringList& tokens );
/*!
* Returns a string serialization of a floating-point matrix. The returned
* string can be deserialized with the GetMatrix() static member function.
*/
static String MatrixToString( const DMatrix& );
/*!
* Deserializes a floating-point matrix from the specified list of
* \a tokens, parsing the necessary tokens starting from the specified
* \a start iterator.
*/
static bool GetMatrix( DMatrix&, StringList::const_iterator& start, const StringList& tokens );
/*!
* Returns a string serialization of a floating-point multivector. The
* returned string can be deserialized with the GetMultiVector() static
* member function.
*/
static String MultiVectorToString( const DMultiVector& );
/*!
* Deserializes a floating-point vector from the specified list of
* \a tokens, parsing the necessary tokens starting from the specified
* \a start iterator.
*/
static bool GetMultiVector( DMultiVector&, StringList::const_iterator& start, const StringList& tokens );
/*!
* Returns a string serialization of an array of floating-point matrices.
* The returned string can be deserialized with the GetMatrices() static
* member function.
*/
static String MatricesToString( const Array<DMatrix>& );
/*!
* Deserializes an array of floating-point matrices from the specified list
* of \a tokens, parsing the necessary tokens starting from the specified
* \a start iterator.
*/
static bool GetMatrices( Array<DMatrix>&, StringList::const_iterator& start, const StringList& tokens );
/*
* Special constructor used for cache search operations.
*/
FileDataCacheItem( const String& p = String() ) : path( p )
{
}
/*
* Copy constructor.
*/
FileDataCacheItem( const FileDataCacheItem& ) = default;
private:
String ToString() const;
bool FromString( const String& s );
bool Load( const IsoString& keyPrefix, int index );
void Save( const IsoString& keyPrefix, int index ) const;
friend class FileDataCache;
};
// ----------------------------------------------------------------------------
/*!
* \class FileDataCache
* \brief Abstract base class of file data cache implementations.
*
* This class provides the necessary infrastructure to implement a file cache
* with persistent storage in module settings data. The main cache access
* functions provided by this class (to add, get and find cache items, as well
* as to clear the cache and query cache properties) are implemented as
* thread-safe routines. This supports applications performing parallel disk
* I/O operations.
*
* You'll find examples of use for this class in standard PixInsight modules
* such as ImageIntegration and SubframeSelector.
*
* \sa FileDataCacheItem, Settings
*/
class PCL_CLASS FileDataCache
{
public:
/*!
* Constructs a new file data cache with the specified settings \a key and
* maximum cache item duration in \a days.
*
* The specified \a key will be used to store all cache data structures
* associated with this object persistently in module settings data. See the
* Settings class for more information on module settings and settings keys.
*
* \warning If the specified number of \a days is &le; 0, existing cache
* items will never expire. This is <em>not recommended</em> and can cause
* problems by increasing the size of stored core application settings
* indiscriminately. In general, the default maximum duration of 30 days is
* quite appropriate for most applications.
*/
FileDataCache( const IsoString& key, int days = 30 );
/*!
* Virtual destructor.
*
* Destroys and deallocates all file data cache items and internal
* structures associated with this object. Note that this refers to data
* currently stored in memory, not to persistent storage in module settings.
* To destroy data stored persistently, the Purge() member function must be
* called explicitly.
*/
virtual ~FileDataCache()
{
Clear();
}
/*!
* Returns an identifying name for this cache object. The default
* implementation returns "File Cache". Derived classes should reimplement
* this function to return more specific identifiers.
*/
virtual String CacheName() const
{
return "File Cache";
}
/*!
* Returns the current cache version. The default implementation returns 1.
*
* \sa MinSupportedVersion()
*/
virtual int Version() const
{
return 1;
}
/*!
* Returns the minimum supported cache version. The default implementation
* returns 1.
*
* No items will be loaded from existing module settings data if their
* version is either less than the value returned by this function, or
* greater than the current cache version. This allows for a basic version
* control system with a range of valid cache versions.
*
* \sa Version()
*/
virtual int MinSupportedVersion() const
{
return 1;
}
/*!
* Returns true iff this cache is currently enabled. A disabled cache does
* not load existing cache items when the Load() member function is invoked.
*/
bool IsEnabled() const
{
return m_enabled;
}
/*!
* Enables this file data cache.
*
* Note that enabling a cache does not force a reload of existing cache
* items; the Load() member function must be called to perform that action.
* In the same way, disabling a cache does not remove any cache item,
* neither from existing internal data structures, nor from persistent
* settings storage.
*/
void Enable( bool enable )
{
m_enabled = enable;
}
/*!
* Returns the maximum duration in days of a valid cache item.
*
* Existing cache items that have not been accessed during a period larger
* than the value returned by this function will not be loaded from
* persistent settings data.
*
* \sa SetDuration(), NeverExpires()
*/
int Duration() const
{
return m_durationDays;
}
/*!
* Sets a new maximum duration in days for valid cache items.
*
* \warning If the specified number of \a days is &le; 0, existing cache
* items will never expire. This is <em>not recommended</em> and can cause
* problems by increasing the size of stored core application settings
* indiscriminately. In general, the default maximum duration of 30 days is
* quite appropriate for most applications.
*
* \sa Duration(), NeverExpires()
*/
void SetDuration( int days )
{
m_durationDays = Max( 0, days );
}
/*!
* Returns true iff existing cache items associated with this object will
* never expire.
*
* \sa Duration(), SetDuration()
*/
bool NeverExpires() const
{
return m_durationDays <= 0;
}
/*!
* Returns the total number of cache items associated with this object.
*
* The returned value corresponds to the number of cache items currently
* stored in internal data structures. This includes cache items loaded from
* existing module settings data as well as items newly created and possibly
* still not copied to persistent storage.
*
* \note This function is thread-safe.
*/
size_type NumberOfItems() const;
/*!
* Returns true iff this cache is empty, i.e. if there are no cache items
* associated with this object.
*
* The returned value is the number of items currently stored in internal
* memory data structures. This does not necessarily equals the total number
* of items currently stored in persistent module settings.
*
* \note This function is thread-safe.
*/
bool IsEmpty() const;
/*!
* Returns the address of a file cache item corresponding to the specified
* file \a path, or nullptr if no such cache item could be found.
*
* \note This function is thread-safe.
*
* \sa Get()
*/
const FileDataCacheItem* Find( const String& path ) const;
/*!
* Destroys and removes all cache items currently associated with this
* object.
*
* Only items stored in internal memory data structures are removed by this
* function. Persistent storage in module settings data is not altered.
*
* \note This function is thread-safe.
*/
void Clear();
/*!
* Adds the specified \a item to this cache.
*
* The item will be stored in internal memory data structures, \e not in
* persistent module settings data. To store cache items persistently, the
* Save() member function must be called for this object.
*
* \note This function is thread-safe.
*/
void Add( const FileDataCacheItem& item );
/*!
* Retrieves a copy of the existing cache data corresponding to the
* specified file \a path in the specified \a item.
*
* Returns true iff a cache item for the specified \a path was found in
* internal memory data structures, and its data were copied. If false is
* returned, the specified \a item will not be modified in any way.
*
* \note This function is thread-safe.
*
* \sa Find()
*/
bool Get( FileDataCacheItem& item, const String& path );
/*!
* Loads existing cache items from persistent module settings data.
*
* All previously existing cache items stored in internal memory structures
* will be destroyed and deallocated before loading new data.
*/
virtual void Load();
/*!
* Writes all cache items associated with this object to persistent module
* settings data.
*/
virtual void Save() const;
/*!
* Destroys and deallocates all existing cache items, including all items
* currently in internal memory data structures as well as all items stored
* in persistent module settings data.
*/
virtual void Purge() const;
protected:
/*!
* Allocates and constructs a new cache item.
*
* Returns a pointer to the newly created cache item. The new item will be
* owned by this object, which will destroy and deallocate it automatically
* when appropriate.
*
* This is a pure virtual member function that must be reimplemented by all
* derived classes. This is because the data transported by a cache item is
* application-specific and cannot be known in advance by this class.
*/
virtual FileDataCacheItem* NewItem() const = 0;
private:
typedef ReferenceSortedArray<FileDataCacheItem> cache_index;
mutable Mutex m_mutex;
cache_index m_cache;
IsoString m_keyPrefix;
int m_durationDays = 30; // <= 0 -> never expires
bool m_enabled = true;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_FileDataCache_h
// ----------------------------------------------------------------------------
// EOF pcl/FileDataCache.h - Released 2022-03-12T18:59:29Z
-123
View File
@@ -1,123 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/FileDataCachePreferencesDialog.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_FileDataCachePreferencesDialog_h
#define __PCL_FileDataCachePreferencesDialog_h
/// \file pcl/FileDataCache.h
#include <pcl/CheckBox.h>
#include <pcl/Dialog.h>
#include <pcl/Label.h>
#include <pcl/PushButton.h>
#include <pcl/Sizer.h>
#include <pcl/SpinBox.h>
namespace pcl
{
// ----------------------------------------------------------------------------
class PCL_CLASS FileDataCache;
/*!
* \class FileDataCachePreferencesDialog
* \brief A dialog to edit file data cache preferences settings
*
* This dialog allows to define persistence and maximum duration for file data
* cache items associated with a given FileDataCache instance. The dialog also
* allows to clear all cache items in memory and/or persistent storage.
*/
class PCL_CLASS FileDataCachePreferencesDialog : public Dialog
{
public:
/*!
* Constructs a new dialog to edit preferences settings for the specified
* \a cache object.
*/
FileDataCachePreferencesDialog( FileDataCache* cache );
private:
FileDataCache* m_cache;
bool m_cacheEnabled;
int m_cacheDuration;
VerticalSizer Global_Sizer;
HorizontalSizer PersistentCache_Sizer;
CheckBox PersistentCache_CheckBox;
HorizontalSizer CacheDuration_Sizer;
Label CacheDuration_Label;
SpinBox CacheDuration_SpinBox;
HorizontalSizer ClearCache_Sizer;
PushButton ClearCache_PushButton;
HorizontalSizer PurgeCache_Sizer;
PushButton PurgeCache_PushButton;
HorizontalSizer Buttons_Sizer;
PushButton OK_PushButton;
PushButton Cancel_PushButton;
void Update();
void e_ValueUpdated( SpinBox& sender, int value );
void e_Click( Button& sender, bool checked );
void e_Return( Dialog& sender, int retVal );
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_FileDataCachePreferencesDialog_h
// ----------------------------------------------------------------------------
// EOF pcl/FileDataCachePreferencesDialog.h - Released 2022-03-12T18:59:29Z
-535
View File
@@ -1,535 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/FileDialog.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_FileDialog_h
#define __PCL_FileDialog_h
/// \file pcl/FileDialog.h
#include <pcl/Defs.h>
#include <pcl/AutoPointer.h>
#include <pcl/File.h>
#include <pcl/StringList.h>
namespace pcl
{
// ----------------------------------------------------------------------------
class FileDialogPrivate;
class OpenFileDialogPrivate;
class SaveFileDialogPrivate;
class GetDirectoryDialogPrivate;
// ----------------------------------------------------------------------------
/*!
* \class FileFilter
* \brief A description of a file type and its associated file extensions
*
* %FileFilter is a simple class to describe a file type and enumerate its
* associated file extensions. That information plays a key role in file
* dialogs as OpenFileDialog and SaveFileDialog.
*
* \sa FileDialog, GetDirectoryDialog, OpenFileDialog, SaveFileDialog
*/
class PCL_CLASS FileFilter
{
public:
/*!
* Constructs an empty %FileFilter object.
*/
FileFilter() = default;
/*!
* Constructs a %FileFilter with the specified \a description and list of
* file \a extensions.
*/
FileFilter( const String& description, const StringList extensions )
{
SetDescription( description );
AddExtensions( extensions );
}
/*!
* Constructs a %FileFilter with the specified \a description and a single
* file \a extension.
*/
FileFilter( const String& description, const String& extension )
{
SetDescription( description );
AddExtension( extension );
}
/*!
* Copy constructor.
*/
FileFilter( const FileFilter& x ) = default;
/*!
* Virtual destructor.
*/
virtual ~FileFilter()
{
}
/*!
* Returns the description of the file type represented by this %FileFilter
* object. Example: "FITS Files".
*/
String Description() const
{
return m_description;
}
/*!
* Sets the \a description of the file type represented by this %FileFilter
* object.
*/
void SetDescription( const String& description )
{
m_description = description.Trimmed();
}
/*!
* Returns a list of file extensions associated to the file type represented
* by this %FileFilter object. Example: ".fit", ".fits", ".fts".
*/
const StringList& Extensions() const
{
return m_extensions;
}
/*!
* Adds a file \a extension associated with the file type represented by
* this %FileFilter object.
*/
void AddExtension( const String& extension );
/*!
* Adds an ordered list of file \a extensions.
*/
void AddExtensions( const StringList& extensions )
{
for ( const String& extension : extensions )
AddExtension( extension );
}
/*!
* Clears the file type description and the list of file extensions.
*/
void Clear();
private:
String m_description;
StringList m_extensions;
String MakeAPIFilter() const;
friend class FileDialogPrivate;
};
// ----------------------------------------------------------------------------
/*!
* \class FileDialog
* \brief Abstract base class of PCL file dialogs
*
* ### TODO: Write a detailed description for %FileDialog.
*
* \sa GetDirectoryDialog, OpenFileDialog, SaveFileDialog, FileFilter
*/
class PCL_CLASS FileDialog
{
public:
/*!
* A list of file filters describing file types and their associated file
* extensions.
*/
typedef Array<FileFilter> filter_list;
/*!
* Constructs a %FileDialog object.
*/
FileDialog();
/*!
* Destroys a %FileDialog object.
*/
virtual ~FileDialog();
/*!
* Returns the caption of this file dialog.
*/
String Caption() const;
/*!
* Sets a new \a caption for this file dialog. If an empty caption is
* specified, the platform will assign a default caption depending on the
* type of dialog: "Open File", "Save File As", and so on.
*/
void SetCaption( const String& caption );
/*!
* Returns the <em>initial path</em> for this file dialog.
*
* If not empty, the initial directory is selected upon dialog execution. If
* the initial path points to a file, that file is set as the initial dialog
* selection, if appropriate.
*/
String InitialPath() const;
/*!
* Sets the <em>initial path</em> for this file dialog. See InitialPath()
* for a full description.
*/
void SetInitialPath( const String& path );
/*!
* Returns a reference to the immutable list of file filters in this file
* dialog.
*/
const filter_list& Filters() const;
/*!
* Defines the list of file \a filters to be used by this file dialog.
*/
void SetFilters( const filter_list& filters );
/*!
* Defines a unique file \a filter to be used by this file dialog.
*/
void SetFilter( const FileFilter& filter )
{
SetFilters( filter_list() << filter );
}
/*!
* Adds a set of file \a filters to the list of filters used by this file
* dialog.
*/
void AddFilters( const filter_list& filters );
/*!
* Adds a file \a filter to the list of filters used by this file dialog.
*/
void AddFilter( const FileFilter& filter )
{
AddFilters( filter_list() << filter );
}
/*!
* Returns a reference to the mutable list of file filters in this file
* dialog.
*
* \deprecated This member function has been deprecated. It is kept just to
* support existing code and must not be used in newly produced code. Use
* SetFilters() instead of this function.
*/
filter_list& Filters();
/*!
* Returns the <em>selected file extension</em> in this file dialog.
*
* If not empty, a file filter containing the specified file extension will
* be selected upon dialog execution. After an accepted call to Execute(),
* this property will store the extension of the first selected file.
*/
String SelectedFileExtension() const;
/*!
* Sets the <em>selected file extension</em> for this file dialog.
* See SelectedFileExtension() for a full description.
*/
void SetSelectedFileExtension( const String& );
/*!
* Modal dialog execution.
*
* Returns true if the dialog has been accepted; false if the dialog has
* been cancelled.
*/
virtual bool Execute() = 0;
protected:
AutoPointer<FileDialogPrivate> p;
};
// ----------------------------------------------------------------------------
/*!
* \class OpenFileDialog
* \brief A modal dialog box to select one or more existing files
*
* ### TODO: Write a detailed description for %FileDialog.
*
* \sa GetDirectoryDialog, FileDialog, SaveFileDialog, FileFilter
*/
class PCL_CLASS OpenFileDialog : public FileDialog
{
public:
/*!
* Constructs an %OpenFileDialog object.
*/
OpenFileDialog();
/*!
* Destroys an %OpenFileDialog object.
*/
virtual ~OpenFileDialog();
/*!
* Loads a set of file filters corresponding to all installed file formats
* that are able to read image files.
*
* The set of file filters loaded by this function will depend on the file
* format modules currently installed on the PixInsight platform. Typically
* it will include formats like FITS, TIFF, JPEG, JPEG2000, and DSLR RAW.
* In the unlikely event that no file format able to read files is installed
* on the platform, the filter set will be empty.
*
* Before the set of format-specific file filters, an additional filter is
* always included that comprises the whole set of reading-capable formats,
* i.e. a first "All known formats" filter is always present.
*/
void LoadImageFilters();
/*!
* Returns true iff this dialog accepts multiple selections.
*
* When multiple selections are enabled, the user can select a list of one
* or more existing files. When this mode is disabled, only a single
* existing file can be selected.
*
* \sa EnableMultipleSelections(), DisableMultipleSelections()
*/
bool AllowsMultipleSelections() const;
/*!
* Enables or disables multiple file selections for this dialog.
*
* \sa DisableMultipleSelections(), AllowsMultipleSelections()
*/
void EnableMultipleSelections( bool enable = true );
/*!
* Disables or enables multiple file selections for this dialog.
*
* This is a convenience member function, equivalent to
* EnableMultipleSelections( !disable ).
*
* \sa DisableMultipleSelections(), AllowsMultipleSelections()
*/
void DisableMultipleSelections( bool disable = true )
{
EnableMultipleSelections( !disable );
}
/*!
*/
bool Execute() override;
/*!
* Returns a reference to the list of selected files.
*
* Each element in the returned list is a full path to a selected file.
*
* When multiple selections are enabled, the returned list may contain one
* or more file paths.
*/
const StringList& FileNames() const;
/*!
* Returns the first selected file path.
*
* Use this member function to access a single file name, when multiple
* selections are disabled, or to the first file name of a multiple
* selection.
*/
String FileName() const;
private:
AutoPointer<OpenFileDialogPrivate> q;
};
// ----------------------------------------------------------------------------
/*!
* \class SaveFileDialog
* \brief A modal dialog box to select a single file name for output
*
* ### TODO: Write a detailed description for %SaveFileDialog.
*
* \sa GetDirectoryDialog, OpenFileDialog, FileDialog, FileFilter
*/
class PCL_CLASS SaveFileDialog : public FileDialog
{
public:
/*!
* Constructs a %SaveFileDialog object
*/
SaveFileDialog();
/*!
* Destroys a %SaveFileDialog object
*/
virtual ~SaveFileDialog();
/*!
* Loads a set of file filters corresponding to all installed file formats
* that are able to write image files.
*
* The set of file filters loaded by this function will depend on the file
* format modules currently installed on the PixInsight platform. Typically
* it will include formats like FITS, TIFF, JPEG, and JPEG2000. In the
* (improbable) event that no file format able to write files is installed
* on the platform, the filter set will be empty.
*/
void LoadImageFilters();
/*!
* Returns true iff <em>overwrite prompts</em> are enabled for this dialog.
*
* When overwrite prompts are enabled, the dialog will request confirmation
* if an existing file is selected.
*
* \sa EnableOverwritePrompt(), DisableOverwritePrompt()
*/
bool IsOverwritePromptEnabled() const;
/*!
* Enables or disables overwrite prompts for this dialog.
*
* \sa DisableOverwritePrompt(), IsOverwritePromptEnabled()
*/
void EnableOverwritePrompt( bool enable = true );
/*!
* Disables or enables overwrite prompts for this dialog.
*
* This is a convenience member function, equivalent to
* EnableOverwritePrompt( !disable )
*
* \sa EnableOverwritePrompt(), IsOverwritePromptEnabled()
*/
void DisableOverwritePrompt( bool disable = true )
{
EnableOverwritePrompt( !disable );
}
/*!
*/
bool Execute() override;
/*!
* Returns the selected file path. A full file path is always returned.
*/
String FileName() const;
private:
AutoPointer<SaveFileDialogPrivate> q;
};
// ----------------------------------------------------------------------------
/*!
* \class GetDirectoryDialog
* \brief A modal dialog box to select an existing directory
*
* ### TODO: Write a detailed description for %GetDirectoryDialog.
*
* \sa FileDialog, OpenFileDialog, SaveFileDialog
*/
class PCL_CLASS GetDirectoryDialog : public FileDialog
{
public:
/*!
* Constructs a %GetDirectoryDialog object
*/
GetDirectoryDialog();
/*!
* Destroys a %GetDirectoryDialog object
*/
virtual ~GetDirectoryDialog();
/*!
*/
bool Execute() override;
/*!
* Returns the selected directory path. A full path is always returned.
*/
String Directory() const;
private:
AutoPointer<GetDirectoryDialogPrivate> q;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_FileDialog_h
// ----------------------------------------------------------------------------
// EOF pcl/FileDialog.h - Released 2022-03-12T18:59:29Z
-495
View File
@@ -1,495 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/FileFormat.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_FileFormat_h
#define __PCL_FileFormat_h
/// \file pcl/FileFormat.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/AutoPointer.h>
#include <pcl/FileFormatBase.h>
namespace pcl
{
// ----------------------------------------------------------------------------
class FileFormatPrivate;
/*!
* \class FileFormat
* \brief High-level interface to an installed image file format.
*
* %FileFormat instances are high-level, managed objects that represent
* installed image file formats in the PixInsight platform. A module creates an
* instance of %FileFormat to gain access to an installed file format through
* <em>intermodule communication</em>.
*
* <b>%FileFormat and %MetaFileFormat</b>
*
* %FileFormat provides a description of the functionality and properties of an
* <em>already installed</em> image file format. Contrarily, by subclassing the
* MetaFileFormat class a module can define and implement a new image file
* format that can be installed in the PixInsight platform. %MetaFileFormat is
* a formal description of a file format, while %FileFormat describes an
* existing (and installed) file format.
*
* As a %MetaFileFormat subclass describes how a format can be instantiated,
* %FileFormat allows a module to create new instances of a file format that
* can be used to access actual image files. %FileFormat doesn't provide any
* file handling functionality; access to image files is provided by the
* FileFormatInstance class.
*
* \sa FileFormatBase, MetaFileFormat, FileFormatInstance
*/
class PCL_CLASS FileFormat : public FileFormatBase
{
public:
/*!
* Constructs a %FileFormat object.
*
* \param nameExtOrMime A format name, file suffix, or MIME type. This
* parameter determines how the PixInsight core
* application looks for an installed file format to which
* this %FileFormat instance will be an interface.
*
* \param toRead When a file suffix or MIME type is specified and this
* parameter is true, a %FileFormat instance will be
* created for an installed file format able to read files
* with the specified file suffix or corresponding to the
* specified MIME type.
*
* \param toWrite When a file suffix or MIME type is specified and this
* parameter is true, a %FileFormat instance will be
* created for an installed file format able to write
* files with the specified file suffix or corresponding
* to the specified MIME type.
*
* When a format name is used as the argument of this constructor,
* %FileFormat will provide access to an installed file format with the
* specified identifier, if there exists one. If the argument is a string
* starting with a dot character, then it is interpreted as a file suffix.
* If the argument has a slash character ('/'), it is interpreted as a MIME
* type specifier. In the latter two cases, the PixInsight core application
* will search for an installed file format able to handle image files with
* the specified file suffix or for the specified MIME type.
*
* In all cases, if no installed file format fits to the specified
* argument(s), this constructor throws an Error exception with the
* corresponding error message. Your code should guarantee that these
* exceptions will be caught and handled appropriately.
*
* When \a nameExtOrMime specifies a format name, the \a toRead and
* \a toWrite parameters are ignored.
*
* Example:
*
* \code
* try
* {
* // Find a format able to read XISF files
* FileFormat xisfFormat( ".xisf", true );
*
* // Create a format instance
* FileFormatInstance myXISFFile( xisfFormat );
*
* // Use the instance to open an existing file
* myXISFFile.Open( "/path/to/test.xisf" );
*
* // Read an image in 32-bit floating point format
* Image img;
* myXISFFile.ReadImage( img );
* // ...
* }
* catch ( Exception& x )
* {
* // Handle errors ...
* }
* \endcode
*
* \note The \a toRead and \a toWrite parameters are false by default, which
* means that no access restrictions are applied by default when creating
* %FileFormat instances.
*/
FileFormat( const String& nameExtOrMime, bool toRead = false, bool toWrite = false );
/*!
* Copy constructor. Constructs an \e alias %FileFormat object that refers
* to the same image file format as the specified object \a fmt.
*/
FileFormat( const FileFormat& fmt );
/*!
* Destroys this %FileFormat object.
*
* \note This destructor does not destroy or uninstall the actual image file
* format it refers to, which is part of the PixInsight core application.
* Only the managed alias object living in the caller module is destroyed.
*/
virtual ~FileFormat();
/*!
*/
IsoString Name() const override;
/*!
*/
StringList FileExtensions() const override;
/*!
*/
IsoStringList MimeTypes() const override;
/*!
*/
uint32 Version() const override;
/*!
*/
String Description() const override;
/*!
*/
String Implementation() const override;
/*!
*/
String Status() const override;
/*!
*/
Bitmap Icon() const override;
/*!
*/
Bitmap SmallIcon() const override;
/*!
*/
bool CanRead() const override;
/*!
*/
bool CanWrite() const override;
/*!
*/
bool CanReadIncrementally() const override;
/*!
*/
bool CanWriteIncrementally() const override;
/*!
*/
bool CanStore8Bit() const override;
/*!
*/
bool CanStore16Bit() const override;
/*!
*/
bool CanStore32Bit() const override;
/*!
*/
bool CanStore64Bit() const override;
/*!
*/
bool CanStoreFloat() const override;
/*!
*/
bool CanStoreDouble() const override;
/*!
*/
bool CanStoreComplex() const override;
/*!
*/
bool CanStoreDComplex() const override;
/*!
*/
bool CanStoreGrayscale() const override;
/*!
*/
bool CanStoreRGBColor() const override;
/*!
*/
bool CanStoreAlphaChannels() const override;
/*!
*/
bool CanStoreResolution() const override;
/*!
*/
bool CanStoreKeywords() const override;
/*!
*/
bool CanStoreICCProfiles() const override;
/*!
*/
bool CanStoreThumbnails() const override;
/*!
*/
bool CanStoreProperties() const override;
/*!
*/
bool CanStoreImageProperties() const override;
/*!
*/
bool CanStoreRGBWS() const override;
/*!
*/
bool CanStoreDisplayFunctions() const override;
/*!
*/
bool CanStoreColorFilterArrays() const override;
/*!
*/
bool SupportsCompression() const override;
/*!
*/
bool SupportsMultipleImages() const override;
/*!
*/
bool SupportsViewProperties() const override;
/*!
*/
bool CanEditPreferences() const override;
/*!
*/
bool UsesFormatSpecificData() const override;
/*!
*/
bool IsDeprecated() const override;
/*!
*/
bool ValidateFormatSpecificData( const void* data ) const override;
/*!
*/
void DisposeFormatSpecificData( void* data ) const override;
/*!
*/
bool EditPreferences() const override;
/*!
* Returns a list with all installed file formats in the PixInsight core
* application.
*/
static Array<FileFormat> AllFormats();
/*!
* Returns true iff the specified file suffix corresponds to an installed
* file format.
*
* \param path A file path including a file suffix identifying an
* image format, such as ".xisf", ".jpg", etc. This
* parameter is case-insensitive. Existence of an actual
* file at the specified path is not verified.
*
* \param toRead True to identify an installed file format module able
* to read files.
*
* \param toWrite True to identify an installed file format module able
* to write files.
*
* \note The \a toRead and \a toWrite parameters are false by default, which
* means that no access restrictions are applied by default.
*/
static bool IsSupportedFileFormatBySuffix( const String& path, bool toRead = false, bool toWrite = false );
/*!
* Returns a list with the full file paths of all supported image files in
* a given directory of the local filesystem.
*
* \param dirPath Path to an existing directory in the local filesystem,
* where supported image files will be looked for.
*
* \param toRead True to select files supported for read operations.
*
* \param toWrite True to select files supported for write operations.
*
* \param recursive True to search for files recursively throughout the
* entire subtree rooted at \a dirPath. False to restrict
* the file search operation to existing files on
* \a dirPath. This parameter is false by default.
*
* \param followLinks True to follow symbolic links to directories and
* files, on platforms supporting symbolic links. This is
* true by default. This parameter is ignored on Windows.
*
* \note The \a toRead and \a toWrite parameters are false by default, which
* means that no access restrictions are applied by default.
*/
static StringList SupportedImageFiles( const String& dirPath, bool toRead = false, bool toWrite = false,
bool recursive = false, bool followLinks = true );
/*!
* Returns a list with the full file paths of all local normalization data
* files in a given directory of the local filesystem.
*
* \param dirPath Path to an existing directory in the local filesystem,
* where local normalization data files will be looked
* for.
*
* \param recursive True to search for files recursively throughout the
* entire subtree rooted at \a dirPath. False to restrict
* the file search operation to existing files on
* \a dirPath. This parameter is false by default.
*
* \param followLinks True to follow symbolic links to directories and
* files, on platforms supporting symbolic links. This is
* true by default. This parameter is ignored on Windows.
*
* Currently this function looks for files with the .xnml suffix (XML local
* normalization data format, XNML).
*
* \sa LocalNormalizationData
*/
static StringList LocalNormalizationFiles( const String& dirPath, bool recursive = false, bool followLinks = true );
/*!
* Returns a list with the full file paths of all drizzle data files in a
* given directory of the local filesystem.
*
* \param dirPath Path to an existing directory in the local filesystem,
* where drizzle data files will be looked for.
*
* \param recursive True to search for files recursively throughout the
* entire subtree rooted at \a dirPath. False to restrict
* the file search operation to existing files on
* \a dirPath. This parameter is false by default.
*
* \param followLinks True to follow symbolic links to directories and
* files, on platforms supporting symbolic links. This is
* true by default. This parameter is ignored on Windows.
*
* Currently this function looks for files with the .drz (compatibility text
* drizzle format) and .xdrz (XML drizzle data format, XDRZ) suffixes.
*
* \sa DrizzleData
*/
static StringList DrizzleFiles( const String& dirPath, bool recursive = false, bool followLinks = true );
/*!
* Returns a list with the full file paths of all ephemeris data files in a
* given directory of the local filesystem.
*
* \param dirPath Path to an existing directory in the local filesystem,
* where ephemeris data files will be looked for.
*
* \param recursive True to search for files recursively throughout the
* entire subtree rooted at \a dirPath. False to restrict
* the file search operation to existing files on
* \a dirPath. This parameter is false by default.
*
* \param followLinks True to follow symbolic links to directories and
* files, on platforms supporting symbolic links. This is
* true by default. This parameter is ignored on Windows.
*
* Currently this function looks for files with the .xeph suffix (Extensible
* Ephemeris Data format, XEPH).
*
* \sa EphemerisFile
*/
static StringList EphemerisFiles( const String& dirPath, bool recursive = false, bool followLinks = true );
private:
AutoPointer<FileFormatPrivate> m_data;
FileFormat( const void* );
const void* Handle() const;
friend class FileFormatPrivate;
friend class FileFormatInstance;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
#endif // __PCL_FileFormat_h
// ----------------------------------------------------------------------------
// EOF pcl/FileFormat.h - Released 2022-03-12T18:59:29Z
-515
View File
@@ -1,515 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/FileFormatBase.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_FileFormatBase_h
#define __PCL_FileFormatBase_h
/// \file pcl/FileFormatBase.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/Bitmap.h>
#include <pcl/StringList.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class FileFormatBase
* \brief Abstract base class for image file format descriptions.
*
* %FileFormatBase defines a number of descriptive properties of a file format
* in the PixInsight platform.
*
* %FileFormatBase is an abstract base class of the MetaFileFormat and
* FileFormat instantiable classes. %MetaFileFormat describes an installable
* file format, while the %FileFormat class provides direct access to an
* installed file format through <em>intermodule communication</em>.
*
* In more practical terms, modules defining new file formats must implement
* derived classes of %MetaFileFormat, while %FileFormat is used by modules
* requiring direct access to image files through installed file formats.
*
* Note that the %FileFormatBase, %MetaFileFormat, %FileFormat,
* FileFormatImplementation and FileFormatInstance classes are conceptually
* parallel to the ProcessBase, MetaProcess, Process, ProcessImplementation and
* ProcessInstance classes, respectively. This is just a reflection of the
* strong object orientation and modularity that characterize the PixInsight
* platform.
*
* \sa MetaFileFormat, FileFormat, FileFormatImplementation, FileFormatInstance
*/
class PCL_CLASS FileFormatBase
{
public:
/*!
* Constructs a %FileFormatBase object.
*/
FileFormatBase()
{
}
/*!
* Destroys this %FileFormatBase object.
*/
virtual ~FileFormatBase() noexcept( false )
{
}
/*!
* Returns the identifier of this file format (also known as the
* <em>format name</em>).
*
* File format identifiers are unique, valid C identifiers.
* Examples: "FITS", "TIFF", "JPEG2000".
*/
virtual IsoString Name() const = 0;
/*!
* Returns the list of file extensions associated to this file format.
*
* The returned list must be a sequence of ".xxx...x" strings in priority
* order. Examples: ".fit", ".fits", ".fts".
*/
virtual StringList FileExtensions() const = 0;
/*!
* Returns a list of MIME types corresponding to the data supported by
* this file format.
*
* The returned list must be a sequence of "media_type/content_type" items
* approved by IANA (see http://www.iana.org/assignments/media-types/), for
* example: "image/fits", "application/fits".
*
* Providing a list of MIME types is not mandatory, but highly recommended
* for all format support modules implementing standard (i.e., recognized by
* IANA) image formats.
*/
virtual IsoStringList MimeTypes() const = 0;
/*!
* Returns a version number for this file format, encoded as a hexadecimal
* number.
*
* For example, version 1.0.5 should be returned as 0x105, and version
* 3.11.5 as 0x3B5. The default return value is 0x100, corresponding to
* version 1.0.0.
*/
virtual uint32 Version() const = 0;
/*!
* Returns a brief description text for this file format.
*
* This function should provide a simple, typically single-line, description
* of this image file format for quick reference. Example: "Flexible Image
* Transport System". The Implementation() member function has been designed
* to provide a more complete description of a format's functionality and
* capabilities.
*/
virtual String Description() const = 0;
/*!
* Returns a descriptive text about this implementation of a particular
* image file format.
*
* This function must provide a brief but sufficiently informative
* description of this file format implementation. The returned description
* will appear on the Format Explorer window, and should provide information
* about how this format has been implemented in a module. Avoid too
* exhaustive descriptions that are better reserved for a technical manual.
* Avoid also describing a file format itself; the information given should
* not intend to replace an official/formal definition of an image format.
*
* Descriptions of file format implementations are always printed on
* PixInsight consoles. This means that the text output functionality of the
* Console class can be used to format the string returned by this function.
* Refer to that class and its documentation for further information.
*/
virtual String Implementation() const = 0;
/*!
* Returns a description of the current status of this file format
* implementation.
*
* This function should return an empty string for normal file format
* implementations. Exceptions to this rule are obsolete or deprecated file
* formats (see the IsDeprecated() member function), deficient
* implementations, or other special cases where the user should be aware of
* important potential problems or limitations.
*
* The output of this function should be essentially plain text with basic
* HTML tags. No console tags should be used.
*/
virtual String Status() const = 0;
/*!
* Returns a <em>large icon</em> image that identifies this format.
*
* The returned image is used to identify all instances of this format
* (e.g., images and files) in the core application's GUI. It is used on the
* Format Explorer window, on image icons of this format, and in general for
* every graphical item related to this format or to an instance of this
* format.
*/
virtual Bitmap Icon() const = 0;
/*!
* Returns a <em>small icon</em> image that identifies this format.
*
* For details on format icon images, see the documentation for Icon().
*
* Small icons are used on interface elements where screen space must be
* preserved. Two good examples are the Format Explorer window and the
* ImageContainer interface.
*/
virtual Bitmap SmallIcon() const = 0;
/*!
* Returns true only if this file format implementation can read an entire
* image in a single operation.
*/
virtual bool CanRead() const = 0;
/*!
* Returns true only if this file format implementation can write an entire
* image in a single operation.
*/
virtual bool CanWrite() const = 0;
/*!
* Returns true only if this file format implementation supports
* <em>incremental read</em> operations on image files.
*
* Incremental read operations allow the PixInsight core application and
* other modules to load images by successive row strips.
*/
virtual bool CanReadIncrementally() const = 0;
/*!
* Returns true only if this file format implementation supports
* <em>incremental write</em> operations on image files.
*
* Incremental write operations allow the PixInsight core application and
* other modules to write images by successive row strips.
*/
virtual bool CanWriteIncrementally() const = 0;
/*!
* Returns true only if this file format implementation can read/write 8-bit
* unsigned integer images
*/
virtual bool CanStore8Bit() const = 0;
/*!
* Returns true only if this file format implementation can read/write
* 16-bit unsigned integer images
*/
virtual bool CanStore16Bit() const = 0;
/*!
* Returns true only if this file format implementation can read/write
* 32-bit unsigned integer images
*/
virtual bool CanStore32Bit() const = 0;
/*!
* Returns true only if this file format implementation can read/write
* 64-bit unsigned integer images
*/
virtual bool CanStore64Bit() const = 0;
/*!
* Returns true only if this file format implementation can read/write
* 32-bit floating point real images (IEEE 754 32-bit <em>single
* precision</em> format for pixel sample values).
*/
virtual bool CanStoreFloat() const = 0;
/*!
* Returns true only if this file format implementation can read/write
* 64-bit floating point real images (IEEE 754 64-bit <em>double
* precision</em> format for pixel sample values).
*/
virtual bool CanStoreDouble() const = 0;
/*!
* Returns true only if this file format implementation can read/write
* 32-bit complex floating point images (IEEE 754 32-bit <em>single
* precision</em> format for components of complex pixel sample values).
*/
virtual bool CanStoreComplex() const = 0;
/*!
* Returns true only if this file format implementation can read/write
* 64-bit complex floating point images (IEEE 754 64-bit <em>double
* precision</em> format for components of complex pixel sample values).
*/
virtual bool CanStoreDComplex() const = 0;
/*!
* Returns true only if this file format implementation can read/write
* grayscale pixel data.
*/
virtual bool CanStoreGrayscale() const = 0;
/*!
* Returns true only if this file format implementation can read/write RGB
* color pixel data.
*/
virtual bool CanStoreRGBColor() const = 0;
/*!
* Returns true only if this file format implementation supports alpha
* channels.
*/
virtual bool CanStoreAlphaChannels() const = 0;
/*!
* Returns true only if this file format implementation can store/retrieve
* image resolution data.
*/
virtual bool CanStoreResolution() const = 0;
/*!
* Returns true only if this file format implementation can embed/extract
* FITS header keyword collections.
*/
virtual bool CanStoreKeywords() const = 0;
/*!
* Returns true only if this file format implementation can embed/extract
* ICC color profiles.
*/
virtual bool CanStoreICCProfiles() const = 0;
/*!
* Returns true only if this file format implementation can embed/extract
* thumbnail images.
*/
virtual bool CanStoreThumbnails() const = 0;
/*!
* Returns true only if this file format implementation can store/retrieve
* data properties associated with format instances or image files.
*
* \note Don't confuse this member function with CanStoreImageProperties().
* This function returns true if the implementation can store properties
* associated with an entire file or format instance, while
* CanStoreImageProperties() returns true if the implementation can store
* properties associated with individual images.
*
* \sa CanStoreImageProperties(), SupportsViewProperties()
*/
virtual bool CanStoreProperties() const = 0;
/*!
* Returns true only if this file format implementation can store/retrieve
* data properties associated with individual images.
*
* \sa CanStoreProperties(), SupportsViewProperties()
*/
virtual bool CanStoreImageProperties() const = 0;
/*!
* Returns true only if this file format implementation can store/retrieve
* RGB working space data.
*/
virtual bool CanStoreRGBWS() const = 0;
/*!
* Returns true only if this file format implementation can store/retrieve
* display function (aka screen transfer function, or STF) parameters.
*/
virtual bool CanStoreDisplayFunctions() const = 0;
/*!
* Returns true only if this file format implementation can store/retrieve
* color filter array (CFA) descriptions.
*/
virtual bool CanStoreColorFilterArrays() const = 0;
/*!
* Returns true only if this file format implementation supports compression
* of pixel data.
*
* This refers to compression of \e source pixels, not to native compression
* schemes used by some file formats.
*
* For example, the compression schemes employed in the JPEG and JPEG2000
* formats must \e not cause this member function to return true. The
* optional ZIP and LZW compressions used in TIFF are the exact kind of
* compressions that must cause this member function to return true.
*/
virtual bool SupportsCompression() const = 0;
/*!
* Returns true only if this file format implementation supports multiple
* images stored in a single file.
*
* For example, multiple images (e.g., taken with different filters) can be
* stored in FITS files by means of FITS image extensions, forming a
* <em>data cube</em> of several images with the same dimensions, or even a
* collection of independent images.
*/
virtual bool SupportsMultipleImages() const = 0;
/*!
* Returns true only if this file format implementation supports data
* properties of different data types such as Float64, UI32Vector, String,
* Complex32, etc.
*
* If this member function returns true, a reimplementation of
* CanStoreProperties() and/or CanStoreImageProperties() (depending on
* format capabilities) must also return true, and the format must implement
* all property data types supported by View objects. For information on
* supported view property types, see the VTYPE_XXX predefined constants in
* PCL API headers.
*
* This function should return false if this format only supports storage of
* BLOB properties, represented as ByteArray objects, or a limited subset of
* view property types.
*
* \sa CanStoreProperties(), CanStoreImageProperties(),
* View::PropertyValue(), View::SetPropertyValue()
*/
virtual bool SupportsViewProperties() const = 0;
/*!
* Returns true only if this file format implementation allows the user to
* edit specific format preferences.
*
* If this function returns true, then the EditPreferences() procedure must
* be reimplemented in a derived class of MetaFileFormat by the module that
* implements this format.
*/
virtual bool CanEditPreferences() const = 0;
/*!
* Returns true only if this file format implementation uses
* <em>format-specific data</em>.
*
* Format-specific data are preserved on a per-instance (say per-file) basis
* by the PixInsight application, who actually knows nothing about them.
*/
virtual bool UsesFormatSpecificData() const = 0;
/*!
* Returns true only if this file format has been deprecated or declared
* obsolete on the PixInsight platform.
*
* When this function returns true, the Status() member function should also
* return information about the current status of this file format,
* including an explanation of the reasons for deprecation.
*/
virtual bool IsDeprecated() const = 0;
/*!
* Validates a <em>format-specific data block</em>.
*
* File formats that use format-specific data reimplement this function to
* validate format-specific data structures. If this function returns true,
* that means that the passed \a data block is a valid format-specific data
* structure for this file format implementation.
*
* This function will be called by the PixInsight core application for
* validation of the \a data block before calling
* FileFormatImplementation::SetFormatSpecificData() and
* DisposeFormatSpecificData().
*/
virtual bool ValidateFormatSpecificData( const void* data ) const = 0;
/*!
* Disposes a <em>format-specific data block</em>.
*
* File formats that use format-specific data reimplement this function to
* destroy and deallocate, as appropriate, their own format-specific data
* structures.
*
* This function will be called by the PixInsight core application with the
* \a data argument pointing to the beginning of a format-specific data
* block. This function will only be called after validation of the data
* block by ValidateFormatSpecificData().
*/
virtual void DisposeFormatSpecificData( void* data ) const = 0;
/*!
* Handles a request to edit format preferences. Returns true if the
* preferences were successfully edited.
*
* When implemented, this procedure should open a dialog box to let the
* user edit format-specific preferences and operating options. This
* function should only return true if the user accepts the new settings
* (e.g. by clicking the dialog's OK button).
*
* \note This member function will never be called if the
* CanEditPreferences() member function is not reimplemented to return true
* in a derived class of MetaFileFormat by the module that implements this
* file format.
*/
virtual bool EditPreferences() const = 0;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
#endif // __PCL_FileFormatBase_h
// ----------------------------------------------------------------------------
// EOF pcl/FileFormatBase.h - Released 2022-03-12T18:59:29Z
-903
View File
@@ -1,903 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/FileFormatImplementation.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_FileFormat_h
#define __PCL_FileFormat_h
/// \file pcl/FileFormatImplementation.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/AutoPointer.h>
#include <pcl/ColorFilterArray.h>
#include <pcl/DisplayFunction.h>
#include <pcl/FITSHeaderKeyword.h>
#include <pcl/ICCProfile.h>
#include <pcl/ImageDescription.h>
#include <pcl/ImageVariant.h>
#include <pcl/MetaFileFormat.h>
#include <pcl/PropertyDescription.h>
#include <pcl/RGBColorSystem.h>
namespace pcl
{
struct FileFormatImplementationPrivate;
// ----------------------------------------------------------------------------
/*!
* \class FileFormatImplementation
* \brief Implementation of a PixInsight file format instance
*
* In the PixInsight/PCL framework, an <em>image file format</em> is formally
* defined as a descendant of the MetaFileFormat class.
* %FileFormatImplementation defines the behavior and functionality of a file
* format instance, which usually (although not necessarily) identifies an
* <em>image file</em> encoded in the corresponding file format.
*
* Note that %MetaFileFormat and %FileFormatImplementation describe and
* implement, respectively, an \e installable image file format in a PixInsight
* module. All installed file formats can be accessed and instantiated by means
* of the FileFormat and FileFormatInstance classes, respectively, through
* intermodule communication mechanisms.
*
* \sa MetaFileFormat, FileFormat, FileFormatInstance
*/
class PCL_CLASS FileFormatImplementation
{
public:
/*!
* Constructs a file format instance.
*
* \param m Pointer to a metaformat that identifies the file format class
* that this file instance belongs to.
*/
FileFormatImplementation( const MetaFileFormat* m );
/*!
* Destroys a file format instance.
*/
virtual ~FileFormatImplementation() noexcept( false );
/*
* FileFormatImplementation instances (e.g., image files) are unique.
*/
/*!
* Copy constructor. This constructor is disabled because file format
* instances represent unique objects (e.g., files or I/O streams).
*/
FileFormatImplementation( const FileFormatImplementation& x ) = delete;
/*!
* Copy assignment. This operator is disabled because file format instances
* represent unique objects (e.g., files or I/O streams).
*/
FileFormatImplementation& operator =( const FileFormatImplementation& ) = delete;
/*!
* Returns a pointer to the \e metaformat of this file format instance.
*
* The metaformat defines the format class this instance belongs to.
*/
const MetaFileFormat* Meta() const
{
return meta;
}
/*!
* Closes an image file (after Open() or Create()).
*/
virtual void Close();
/*!
* Returns true iff this file is currently open.
*/
virtual bool IsOpen() const;
/*!
* Returns the current file path in this instance. If no file path has been
* set yet (by calling Open() or Create()), this member function should
* return an empty string.
*/
virtual String FilePath() const;
// Reader functionality
/*!
* Opens an image file for reading and/or information retrieval.
*
* \param filePath File path to a file that will be opened. The core
* PixInsight application always passes full file paths to existing
* files. However, other modules that may call this member function
* (through intermodule communication) may not behave in the same
* way. A module must be prepared to receive relative file path
* specifications, and even paths to files that don't exist, in
* this argument.
*
* \param hints A string containing a (possibly empty) list of \e hints
* intended to modify the way an image file is opened and/or the
* way image data are to be read and decoded. A format module can
* simply ignore all of these hints, or just look for one or more
* hints that it recognizes and supports, ignoring others. When two
* or more hints are specified, they must be separated by space
* characters (0x20). Most standard file formats support hints. For
* example, the standard DSLR_RAW format recognizes the "raw" hint
* to force reading pure raw data (no deBayerization, no black
* pedestal subtraction, no white balancing) irrespective of the
* current DSLR RAW format settings.
*
* This function must return a dynamic array of ImageDescription structures
* that describes the image(s) stored in the opened image file. Each
* %ImageDescription structure contains ImageInfo and ImageOptions objects
* that describe both basic image parameters (as geometry and color space)
* and format-independent image options (pixel format, embedded data, etc).
*
* In the event of error, a reimplementation of this member function should
* throw a PCL exception. Thrown exceptions will be caught and processed by
* internal PCL code.
*/
virtual ImageDescriptionArray Open( const String& filePath, const IsoString& hints );
/*!
* Selects the image at the specified zero-based \a index in this file.
*
* This member function will only be called for file formats that support
* multiple images stored in a single file. It will never be called if the
* MetaFileFormat::SupportsMultipleImages() member function has not been
* reimplemented to return true in the metaformat class for this instance.
*/
virtual void SelectImage( int index );
/*!
* Returns the current zero-based image index in this file.
*
* This member function will only be called for file formats that support
* multiple images stored in a single file. It will never be called if the
* MetaFileFormat::SupportsMultipleImages() member function has not been
* reimplemented to return true in the metaformat class for this instance.
*/
virtual int SelectedImageIndex() const;
/*!
* Returns a <em>format-specific data block</em> for the current image in
* this file, or nullptr if no such data have been retrieved.
*
* See SetFormatSpecificData() for a description of format specific data
* functionality in PCL.
*/
virtual void* FormatSpecificData() const;
/*!
* Provides a human-readable summary of format-specific properties for the
* current image in this file.
*
* The returned string should include format-specific information, \e not
* generic image information. For example, don't include image dimensions,
* color space, and other things that the PixInsight core application
* already knows.
*
* \note The default implementation returns an empty string.
*/
virtual String ImageFormatInfo() const
{
return String();
}
/*!
* Extraction of the ICC color profile associated with the current image in
* this file. If no ICC color profile is defined for the current image, this
* function should return a null (empty) %ICCProfile object.
*
* This member function will never be called if the underlying file format
* does not support storage of ICC color profiles. See
* FileFormat::CanStoreICCProfiles().
*/
virtual ICCProfile ReadICCProfile();
/*!
* Extraction of the RGB working space associated with the current image in
* this file. If no RGBWS is defined for the current image, this function
* should return a default RGBColorSystem object (see RGBColorSystem::sRGB).
*
* This member function will never be called if the underlying file format
* does not support storage of RGB working spaces. See
* FileFormat::CanStoreRGBWS().
*/
virtual RGBColorSystem ReadRGBWorkingSpace();
/*!
* Extraction of the display function associated with the current image in
* this file. If no display function is defined for the current image, this
* function should return an identity display function (see
* DisplayFunction's default constructor).
*
* This member function will never be called if the underlying file format
* does not support storage of display functions. See
* FileFormat::CanStoreDisplayFunctions().
*/
virtual DisplayFunction ReadDisplayFunction();
/*!
* Extraction of the color filter array (CFA) for the current image in this
* file. If no CFA is defined for the current image, this function should
* return an empty CFA (see ColorFilterArray's default constructor).
*
* This member function will never be called if the underlying file format
* does not support storage of color filter arrays. See
* FileFormat::CanStoreColorFilterArrays().
*/
virtual ColorFilterArray ReadColorFilterArray();
/*!
* Extraction of the embedded thumbnail for the current image in this file.
* If the current image does not embed a thumbnail image, this function
* should return an empty 8-bit integer image.
*/
virtual UInt8Image ReadThumbnail();
/*!
* Extraction of the list of embedded %FITS keywords for the current image
* in this file. If the current image embeds no %FITS keywords, this
* function should return an empty array.
*/
virtual FITSKeywordArray ReadFITSKeywords();
/*!
* Returns a description of all data properties associated with this file.
* For each data property, the returned array provides information on the
* unique identifier of a property and its data type.
*
* Returns an empty array if there are no properties stored for this file.
*
* This member function will never be called if the underlying file format
* does not support data properties. See FileFormat::CanStoreProperties().
*
* \note Don't confuse this member function with ImagePropertyDescriptions(). This
* function returns information on the properties of the \e whole image
* file, while %ImagePropertyDescriptions() provides the properties of the currently
* selected image.
*/
virtual PropertyDescriptionArray PropertyDescriptions();
/*!
* Extraction of a data property with the specified unique identifier.
*
* If no property with the specified identifier exists associated with this
* file, an invalid Variant object should be returned.
*
* This member function will never be called if the underlying file format
* does not support data properties. See FileFormat::CanStoreProperties().
*
* \note Don't confuse this member function with ReadImageProperty(). This
* function returns the value of a given property of the \e whole image
* file, while %ReadImageProperty() returns the value of a property of the
* currently selected image.
*/
virtual Variant ReadProperty( const IsoString& property );
/*!
* Returns a description of all data properties associated with the current
* image in this file. For each data property, the returned array provides
* information on the unique identifier of a property and its data type.
*
* Returns an empty array if there are no properties stored for the current
* image in this file.
*
* This member function will never be called if the underlying file format
* does not support data properties for individual images. See
* FileFormat::CanStoreImageProperties().
*/
virtual PropertyDescriptionArray ImagePropertyDescriptions();
/*!
* Extraction of a data property of the current image with the specified
* unique identifier.
*
* If no property with the specified identifier exists associated with the
* current image in this file, an invalid Variant object should be returned.
*
* This member function will never be called if the underlying file format
* does not support data properties for individual images. See
* FileFormat::CanStoreImageProperties().
*/
virtual Variant ReadImageProperty( const IsoString& property );
/*!
* Reads the current image in 32-bit floating point format.
*/
virtual void ReadImage( pcl::Image& image );
/*!
* Reads the current image in 64-bit floating point format.
*/
virtual void ReadImage( pcl::DImage& image );
/*!
* Reads the current image in 8-bit unsigned integer format.
*/
virtual void ReadImage( UInt8Image& image );
/*!
* Reads the current image in 16-bit unsigned integer format.
*/
virtual void ReadImage( UInt16Image& image );
/*!
* Reads the current image in 32-bit unsigned integer format.
*/
virtual void ReadImage( UInt32Image& image );
/*!
* Returns true iff this instance can perform incremental read operations.
*
* The default implementation returns true. Do not confuse this member
* function with MetaFileFormat::CanReadIncrementally(), which tells the
* PixInsight core application if a given file format has the capability of
* performing incremental file reads in general. The value returned by this
* function refers specifically to the file format instance (e.g., a
* particular file) represented by this object.
*/
virtual bool CanReadIncrementally() const
{
return true; // allow incremental reads if the format supports them
}
/*!
* Incremental read in 32-bit floating point sample format.
*
* \param[out] buffer Address of the destination sample buffer.
*
* \param startRow First pixel row to read.
*
* \param rowCount Number of pixel rows to read.
*
* \param channel Channel index to read.
*
* Incremental read operations allow the PixInsight core application and
* other modules to load images by successive row strips.
*
* To implement incremental reading,
* MetaFileFormat::CanReadIncrementally() must be reimplemented to return
* true in the metaformat class for this file instance; otherwise this
* member function will never be called. Furthermore, the
* FileFormatImplementation::CanReadIncrementally() member function must
* return true for the format instance represented by this object.
*/
virtual void ReadSamples( pcl::Image::sample* buffer, int startRow, int rowCount, int channel );
/*!
* Incremental read in 64-bit floating point sample format.
*
* This is an overloaded member function for the DImage type; see
* ReadSamples( Image::sample*, int, int, int, int ) for a full description.
*/
virtual void ReadSamples( pcl::DImage::sample* buffer, int startRow, int rowCount, int channel );
/*!
* Incremental read in 8-bit unsigned integer sample format.
*
* This is an overloaded member function for the UInt8Image type; see
* ReadSamples( Image::sample*, int, int, int, int ) for a full description.
*/
virtual void ReadSamples( UInt8Image::sample* buffer, int startRow, int rowCount, int channel );
/*!
* Incremental read in 16-bit unsigned integer sample format.
*
* This is an overloaded member function for the UInt16Image type; see
* ReadSamples( Image::sample*, int, int, int, int ) for a full description.
*/
virtual void ReadSamples( UInt16Image::sample* buffer, int startRow, int rowCount, int channel );
/*!
* Incremental read in 32-bit unsigned integer sample format.
*
* This is an overloaded member function for the UInt32Image type; see
* ReadSamples( Image::sample*, int, int, int, int ) for a full description.
*/
virtual void ReadSamples( UInt32Image::sample* buffer, int startRow, int rowCount, int channel );
/*!
* Returns true iff the last file read operation was \e inexact.
*
* The PixInsight application invokes this function just after successful
* completion of a call to ReadImage() or Read(). If a file format instance
* reads (or might read) source images inexactly, (e.g., by applying a
* rounding function to source sample values), then this function must be
* reimplemented to return true, as appropriate.
*
* \note The default implementation of this function returns false, so
* exact read operations are assumed by default.
*/
virtual bool WasInexactRead() const
{
return false; // exact read operations assumed by default
}
// Writer functionality
/*!
* Query image options and format-specific data before creating a new image
* file. Returns true if the file creation operation can continue; false if
* it should be aborted.
*
* \param[out] options Reference to a dynamic array of ImageOptions
* objects. On output, each of these objects must provide a general
* description of an image stored in a file instance of this file
* format. A file format module is responsible for setting the
* appropriate values in the passed structures, which will be used
* to generate a new file through a subsequent call to Create().
* Formats that can store multiple images per file can receive more
* than one %ImageOptions structure stored in this array. Formats
* that don't support multiple images can safely ignore all
* structures but the first one in this array.
*
* \param[out] formatOptions Reference to a dynamic array of
* <em>format-specific data blocks</em>. Each void pointer in this
* array can be either zero or point to valid format-specific data
* for the format of this instance. This array can be empty if no
* format-specific data is being set. See the
* SetFormatSpecificData() member function for more information on
* format-specific data blocks.
*
* If the PixInsight application calls this function, it does so just before
* calling Create(). Typically, this happens as part of a <tt>File > Save
* As</tt> operation. Other modules can also invoke this function through
* intermodule communication. Format modules should open a dialog box to let
* the user modify some working options, as appropriate; then they should
* return true unless the user cancels the dialog.
*
* \note The default implementation of this function simply returns true
* without opening an options dialog.
*/
virtual bool QueryOptions( Array<ImageOptions>& options, Array<void*>& formatOptions )
{
return true;
}
/*!
* Creates an image file for writing.
*
* \param filePath Path to a file that will be created. If a file exists
* at the same path, it will be overwritten and its current
* contents will be lost. The PixInsight core application always
* passes full file paths to existing files. However, other modules
* that may call this member function (through intermodule
* communication) may not behave in the same way. A module must be
* prepared to receive relative file path specifications, and even
* invalid paths, in this argument.
*
* \param numberOfImages This is the number of images that will be written
* to the file after creation. It can be zero if an empty file is
* being created, and also less than zero if the number of images
* is unknown or cannot be defined at the point of creation.
* Although the PixInsight core application will always pass the
* exact number of images that will be written, other modules that
* can call this member function (through intermodule
* communication) might not behave so accurately. Therefore, format
* modules should be flexible enough as to not depend on an
* accurate count of images passed here. For a format that does not
* support empty files or multiple images stored in a single file,
* a reimplementation of this member function should throw an Error
* exception if this value is zero or not equal to one,
* respectively.
*
* \param hints A string containing a (possibly empty) list of \e hints
* intended to modify the way an image file is generated and/or the
* way image data are to be encoded and written. A format module
* can simply ignore all of these hints, or just look for one or
* more hints that it recognizes and supports, ignoring others.
* When two or more hints are specified, they must be separated by
* space characters (0x20). Many standard file formats support some
* hints. For example, the standard JPEG format recognizes the
* "quality" hint to force generation of a JPEG image with a given
* quality level in the range 1 to 100, irrespective of the current
* JPEG format settings.
*
* In the event of error, a reimplementation of this member function should
* throw a PCL exception. Thrown exceptions will be caught and processed by
* internal PCL code.
*/
virtual void Create( const String& filePath, int numberOfImages, const IsoString& hints );
/*!
* Specifies an identifier for the next image that will be written or
* created in this file.
*
* \note Reimplementation of this member function is optional. The default
* implementation does nothing (ignores image identifiers).
*/
virtual void SetId( const IsoString& id )
{
}
/*!
* Specifies a set of format-independent image \a options for the next image
* that will be written or created in this file.
*
* \note Reimplementation of this member function is optional. The default
* implementation does nothing (ignores format-independent image options).
*/
virtual void SetOptions( const ImageOptions& options )
{
}
/*!
* Specifies a <em>format-specific data block</em> for the next image that
* will be written or created in this file.
*
* Format-specific data are arbitrary data blocks; the PixInsight core
* application knows nothing about them except that it passes them among
* instances, even instances of different file formats.
*
* Format-specific data are used by file formats that need working
* parameters that must persist across different file instances. In such
* cases, derived classes should implement suitable mechanisms to identify
* and validate their own data.
*
* For example, file formats that use variable compression schemes usually
* reimplement this member function, along with FormatSpecificData(), to
* keep track of a compression ratio, along with other private data items.
*
* To implement format-specific data support,
* MetaFileFormat::UsesFormatSpecificData() must be reimplemented to return
* true in the metaformat class for this file instance; otherwise this
* member function will never be called.
*
* Before calling this function, the PixInsight core application will call
* MetaFileFormat::ValidateFormatSpecificData() for the same \a data block.
* If the validation routine returns false, this function will not be called
* for the \a data block that failed the validation test.
*/
virtual void SetFormatSpecificData( const void* data );
/*!
* Specifies an ICC profile to be embedded in the next image written or
* created in this file.
*/
virtual void WriteICCProfile( const ICCProfile& icc );
/*!
* Specifies the parameters of an RGB working space that will be embedded in
* the next image written or created in this file.
*/
virtual void WriteRGBWorkingSpace( const RGBColorSystem& rgbws );
/*!
* Specifies a display function that will be embedded in the next image
* written or created in this file.
*/
virtual void WriteDisplayFunction( const DisplayFunction& df );
/*!
* Specifies a color filter array (CFA) that will be embedded in the next
* image written or created in this file.
*/
virtual void WriteColorFilterArray( const ColorFilterArray& cfa );
/*!
* Specifies a thumbnail \a image to be embedded in the next image written
* or created in this file.
*/
virtual void WriteThumbnail( const pcl::UInt8Image& image );
/*!
* Specifies a set of %FITS \a keywords to be embedded in the next image
* written or created in this file.
*/
virtual void WriteFITSKeywords( const FITSKeywordArray& keywords );
/*!
* Specifies a data property to be embedded in this file.
*
* \param property Unique identifier of the data property.
*
* \param value Property value.
*
* This member function will never be called if the underlying file format
* does not support data properties. See FileFormat::CanStoreProperties().
*
* \note Don't confuse this member function with WriteImageProperty(). This
* function defines a property for the \e whole file, while
* %WriteImageProperty() defines a property of the currently selected image.
*/
virtual void WriteProperty( const IsoString& property, const Variant& value );
/*!
* Specifies a data property to be embedded in the next image written or
* created in this file.
*
* \param property Unique identifier of the data property.
*
* \param value Property value.
*
* This member function will never be called if the underlying file format
* does not support data properties for individual images. See
* FileFormat::CanStoreImageProperties().
*/
virtual void WriteImageProperty( const IsoString& property, const Variant& value );
/*!
* Writes a 32-bit floating point image to this file.
*/
virtual void WriteImage( const pcl::Image& image );
/*!
* Writes a 64-bit floating point image to this file.
*/
virtual void WriteImage( const pcl::DImage& image );
/*!
* Writes an 8-bit unsigned integer image to this file.
*/
virtual void WriteImage( const UInt8Image& image );
/*!
* Writes a 16-bit unsigned integer image to this file.
*/
virtual void WriteImage( const UInt16Image& image );
/*!
* Writes a 32-bit unsigned integer image to this file.
*/
virtual void WriteImage( const UInt32Image& image );
/*!
* Creates a new image with the geometry and color space as specified by an
* ImageInfo structure. The newly created image will be written by
* subsequent incremental write operations.
*
* The sample data type and other format-independent and format-specific
* image parameters have been specified by previous calls to SetOptions()
* and SetFormatSpecificData().
*
* \note This member function must be reimplemented by all derived classes
* supporting incremental write operations.
*/
virtual void CreateImage( const ImageInfo& info );
/*!
* Closes the image that has been created by a previous call to
* CreateImage().
*
* \note This member function must be reimplemented by all derived classes
* supporting incremental write operations.
*/
virtual void CloseImage();
/*!
* Returns true iff this instance can perform incremental write operations.
*
* The default implementation returns true. Do not confuse this member
* function with MetaFileFormat::CanWriteIncrementally(), which tells the
* PixInsight core application if a given file format has the capability of
* performing incremental file writes in general. The value returned by this
* function refers specifically to the file format instance (e.g., a
* particular file) represented by this object.
*/
virtual bool CanWriteIncrementally() const
{
return true; // allow incremental writes if the format supports them
}
/*!
* Incremental write of 32-bit floating point pixel samples.
*
* \param buffer Address of the source sample buffer.
*
* \param startRow First pixel row to write.
*
* \param rowCount Number of pixel rows to write.
*
* \param channel Channel index to write.
*
* Incremental write operations allow the PixInsight core application and
* other modules to generate images by successive row strips.
*
* To implement incremental writing,
* MetaFileFormat::CanWriteIncrementally() must be reimplemented to return
* true in the metaformat class for this file instance; otherwise this
* member function will never be called. Furthermore, the
* FileFormatImplementation::CanWriteIncrementally() member function must
* return true for the format instance represented by this object.
*/
virtual void WriteSamples( const pcl::Image::sample* buffer, int startRow, int rowCount, int channel );
/*!
* Incremental write of a 64-bit floating point image.
*
* This is an overloaded member function for the DImage type; see
* WriteSamples( const Image::sample*, int, int, int ) for a full description.
*/
virtual void WriteSamples( const pcl::DImage::sample* buffer, int startRow, int rowCount, int channel );
/*!
* Incremental write of an 8-bit unsigned integer image.
*
* This is an overloaded member function for the UInt8Image type; see
* WriteSamples( const Image::sample*, int, int, int ) for a full description.
*/
virtual void WriteSamples( const UInt8Image::sample* buffer, int startRow, int rowCount, int channel );
/*!
* Incremental write of a 16-bit unsigned integer image.
*
* This is an overloaded member function for the UInt16Image type; see
* WriteSamples( const Image::sample*, int, int, int ) for a full description.
*/
virtual void WriteSamples( const UInt16Image::sample* buffer, int startRow, int rowCount, int channel );
/*!
* Incremental write of a 32-bit unsigned integer image.
*
* This is an overloaded member function for the UInt32Image type; see
* WriteSamples( const Image::sample*, int, int, int ) for a full description.
*/
virtual void WriteSamples( const UInt32Image::sample* buffer, int startRow, int rowCount, int channel );
/*!
* Returns true iff the last file write operation in this file was \e lossy.
*
* The PixInsight core application invokes this function just after
* successful completion of a call to WriteImage() or Write(). If a file
* format instance writes (or might write) lossy image data (e.g., by
* applying some lossy compression scheme), then this function must be
* reimplemented to return true, as appropriate.
*
* \note The default implementation of this function returns false, so
* lossless write operations are assumed by default.
*/
virtual bool WasLossyWrite() const
{
return false; // lossless write operations assumed by default
}
protected:
/*
* The file format to which this instance belongs.
*/
const MetaFileFormat* meta = nullptr;
private:
/*
* Internal stuff to automate low-level C API communication.
*/
AutoPointer<FileFormatImplementationPrivate> m_data;
ImageDescriptionArray m_description; // used exclusively by FileFormatDispatcher
void BeginPrivate();
void BeginICCProfileExtraction();
const ICCProfile& GetICCProfile() const;
void EndICCProfileExtraction();
void BeginRGBWSExtraction();
const RGBColorSystem& GetRGBWS() const;
void EndRGBWSExtraction();
void BeginDisplayFunctionExtraction();
const DisplayFunction& GetDisplayFunction() const;
void EndDisplayFunctionExtraction();
void BeginColorFilterArrayExtraction();
const ColorFilterArray& GetColorFilterArray() const;
void EndColorFilterArrayExtraction();
void BeginThumbnailExtraction();
const UInt8Image& GetThumbnail() const;
void EndThumbnailExtraction();
void BeginKeywordExtraction();
size_type NumberOfKeywords() const;
bool GetNextKeyword( FITSHeaderKeyword& ) const;
void EndKeywordExtraction();
void BeginPropertyExtraction();
const Variant& GetProperty( const IsoString& );
void EndPropertyExtraction();
void BeginImagePropertyExtraction();
const Variant& GetImageProperty( const IsoString& );
void EndImagePropertyExtraction();
void BeginICCProfileEmbedding();
void SetICCProfile( const ICCProfile& );
void EndICCProfileEmbedding();
void BeginRGBWSEmbedding();
void SetRGBWS( const RGBColorSystem& );
void EndRGBWSEmbedding();
void BeginDisplayFunctionEmbedding();
void SetDisplayFunction( const DisplayFunction& );
void EndDisplayFunctionEmbedding();
void BeginColorFilterArrayEmbedding();
void SetColorFilterArray( const ColorFilterArray& );
void EndColorFilterArrayEmbedding();
void BeginThumbnailEmbedding();
void SetThumbnail( const UInt8Image& );
void EndThumbnailEmbedding();
void BeginKeywordEmbedding();
void AddKeyword( const FITSHeaderKeyword& );
void EndKeywordEmbedding();
void BeginPropertyEmbedding();
void SetProperty( const IsoString&, const Variant& );
void EndPropertyEmbedding();
void BeginImagePropertyEmbedding();
void SetImageProperty( const IsoString&, const Variant& );
void EndImagePropertyEmbedding();
friend class FileFormatDispatcher;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
#endif // __PCL_FileFormat_h
// ----------------------------------------------------------------------------
// EOF pcl/FileFormatImplementation.h - Released 2022-03-12T18:59:29Z
File diff suppressed because it is too large Load Diff
-442
View File
@@ -1,442 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/FileInfo.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_FileInfo_h
#define __PCL_FileInfo_h
/// \file pcl/FileInfo.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/File.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class FileInfo
* \brief Platform-independent information on file and directory items.
*
* ### TODO: Write a detailed description for %FileInfo.
*/
class PCL_CLASS FileInfo
{
public:
/*!
* Default constructor. Constructs an empty %FileInfo object without any
* information on existing file or directory items.
*/
FileInfo()
{
Clear();
}
/*!
* Constructs a %FileInfo object with information retrieved for the
* specified file or directory \a path.
*/
FileInfo( const String& path )
{
Refresh( path );
}
/*!
* Copy constructor.
*/
FileInfo( const FileInfo& ) = default;
/*!
* Virtual destructor.
*/
virtual ~FileInfo()
{
}
/*!
* Assignment operator. Returns a reference to this object.
*/
FileInfo& operator =( const FileInfo& ) = default;
/*!
* Returns the absolute path of this file or directory.
*/
const String& Path() const
{
return m_path;
}
/*!
* Returns the Windows drive component of the path in this object, or an
* empty string if the path does not include a Windows drive specification.
*
* This function only makes sense on Windows. On UNIX and Linux operating
* systems, this function always returns an empty string.
*/
String Drive() const
{
return File::ExtractDrive( m_path );
}
/*!
* Returns the parent directory component of the path in this object, or an
* empty string if the path does not include a parent directory.
*
* On Windows, the drive component of the path is \e not included.
*
* Examples:
*
* \li In '/foo.tar.gz' the directory is '/'.
* \li In '/foo/bar.tar.gz' the directory is '/foo'.
* \li In 'foo/bar.tar.gz' the directory is 'foo'.
* \li In 'C:/Foo/Bar.txt' the directory is '/Foo'.
*/
String Directory() const
{
return File::ExtractDirectory( m_path );
}
/*!
* Returns the file name component of the path in this object, or an empty
* string if the path does not include a name.
*
* The file extension or suffix is \e not included.
*
* Examples:
*
* \li In '/foo/bar.tar.gz' the name is 'bar'.
* \li In 'C:/Foo/Bar.txt' the name is 'Bar'.
*/
String Name() const
{
return File::ExtractName( m_path );
}
/*!
* Returns the file extension component of the path in this object, or an
* empty string if the path does not include an extension.
*
* The returned extension \e includes the initial dot separator.
*
* Examples:
*
* \li In '/foo/bar.tar.gz' the extension is '.gz'.
* \li In 'C:/Foo/Bar.txt' the extension is '.txt'.
*/
String Extension() const
{
return File::ExtractExtension( m_path );
}
/*!
* A synonym for Extension().
*/
String Suffix() const
{
return Extension();
}
/*!
* Returns the complete suffix of the path in this object, or an empty
* string if the path does not include a suffix.
*
* The returned string \e includes the initial dot separator.
*
* The complete suffix is the rightmost substring of the path, starting with
* the first occurrence of a dot character. For example, in 'foo.tar.gz' the
* complete suffix is '.tar.gz'.
*/
String CompleteSuffix() const
{
return File::ExtractCompleteSuffix( m_path );
}
/*!
* Returns the name and extension of the path in this object. Calling this
* member function is functionally equivalent to: Name() + Extension().
*/
String NameAndExtension() const
{
return File::ExtractNameAndExtension( m_path );
}
/*!
* A synonym for NameAndExtension().
*/
String NameAndSuffix() const
{
return NameAndExtension();
}
/*!
* Returns true iff this object represents an existing file or directory.
*/
bool Exists() const
{
return m_exists;
}
/*!
* Returns a constant reference to the FileAttributes flags for this file or
* directory.
*/
const FileAttributes& Attributes() const
{
return m_attributes;
}
/*!
* Returns true iff this object represents an existing directory.
*/
bool IsDirectory() const
{
return m_attributes.IsFlagSet( FileAttribute::Directory );
}
/*!
* Returns true iff this object represents an existing file.
*/
bool IsFile() const
{
return m_attributes.IsFlagSet( FileAttribute::Regular );
}
/*!
* Returns true iff this object represents a symbolic link.
*
* This member function only makes sense on UNIX/Linux platforms. On Windows
* it always returns false.
*/
bool IsSymbolicLink() const
{
return m_attributes.IsFlagSet( FileAttribute::SymbolicLink );
}
/*!
* Returns the target path of this symbolic link, or an empty string if this
* object does not represent a symbolic link.
*
* This member function only makes sense on UNIX/Linux platforms. On Windows
* it always returns an empty string.
*/
String SymbolicLinkTarget() const;
/*!
* Returns true iff this object represents a hidden file or directory.
*
* On Windows, this member function returns true if the file or directory
* represented by this object has the hidden attribute set. On UNIX and
* Linux operating systems, this function returns true when the file or
* directory name begins with a dot character.
*/
bool IsHidden() const
{
return m_attributes.IsFlagSet( FileAttribute::Hidden );
}
/*!
* Returns true iff the user id and group id of the caller process have read
* access permission for the item represented by this object.
*/
bool IsReadable() const
{
return m_readable;
}
/*!
* Returns true iff the user id and group id of the caller process have write
* access permission for the item represented by this object.
*/
bool IsWritable() const
{
return m_writable;
}
/*!
* Returns true iff the user id and group id of the caller process have
* execution access permission for the item represented by this object.
*
* This member function only makes sense on UNIX/Linux platforms. On Windows
* it always returns false.
*
* On POSIX systems, this function returns true only if the item represented
* has the S_IXUSR file mode bit set. This means that this function will
* normally return true for directories, since S_IXUSR/S_IXGRP/S_IXOTH
* represent standard search permissions for a directory.
*/
bool IsExecutable() const
{
return m_executable;
}
/*!
* Returns the size in bytes of the file or directory item represented by
* this object.
*
* If this object represents a directory, a fixed size (usually 4096 bytes)
* is always returned on UNIX and Linux systems. On Windows, zero is always
* returned for directories.
*/
fsize_type Size() const
{
return m_size;
}
/*!
* Returns the number of existing hard links to the file or directory item
* represented by this object.
*
* This member function only makes sense on UNIX/Linux platforms. On Windows
* it always returns zero.
*/
int NumberOfHardLinks() const
{
return m_numberOfHardLinks;
}
/*!
* Returns the user id of the owner of the file or directory item
* represented by this object.
*
* This member function only makes sense on UNIX/Linux platforms. On Windows
* it always returns zero.
*/
int UserId() const
{
return m_userId;
}
/*!
* Returns the group id of the owner of the file or directory item
* represented by this object.
*
* This member function only makes sense on UNIX/Linux platforms. On Windows
* it always returns zero.
*/
int GroupId() const
{
return m_groupId;
}
/*!
* Returns a constant reference to a FileTime structure corresponding to the
* creation time of this file or directory.
*/
const FileTime& TimeCreated() const
{
return m_created;
}
/*!
* Returns a constant reference to a FileTime structure corresponding to the
* last access time of this file or directory.
*/
const FileTime& LastAccessed() const
{
return m_lastAccessed;
}
/*!
* Returns a constant reference to a FileTime structure corresponding to the
* last modification time of this file or directory.
*/
const FileTime& LastModified() const
{
return m_lastModified;
}
/*!
* Retrieves up-to-date information for the item represented by this object.
*/
void Refresh();
/*!
* Retrieves information for the specified \a path.
*/
void Refresh( const String& path );
/*!
* Clears all the information in this object, leaving it in an invalid state
* corresponding to a nonexistent item.
*/
void Clear();
private:
String m_path; // full file or directory path
FileAttributes m_attributes; // item attributes
fsize_type m_size; // file size in bytes
int m_numberOfHardLinks; // number of existing hard links to this file
int m_userId; // user id of the file owner
int m_groupId; // group id of the file owner
FileTime m_created; // creation time
FileTime m_lastAccessed; // time of last access
FileTime m_lastModified; // time of last change
bool m_exists; // item exists
bool m_readable; // caller has read permission
bool m_writable; // caller has write permission
bool m_executable; // caller has execute permission
// Clears everything but *preserves* m_path
void ClearData();
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_FileInfo_h
// ----------------------------------------------------------------------------
// EOF pcl/FileInfo.h - Released 2022-03-12T18:59:29Z
-409
View File
@@ -1,409 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Flags.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Flags_h
#define __PCL_Flags_h
/// \file pcl/Flags.h
#include <pcl/Defs.h>
#ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
namespace pi
{
class GlobalSettings;
}
#endif
namespace pcl
{
// ----------------------------------------------------------------------------
template <bool> struct FlagType {};
template <> struct FlagType<true> { typedef unsigned type; };
template <> struct FlagType<false> { typedef int type; };
// ----------------------------------------------------------------------------
/*!
* \class Flags
* \brief A type-safe collection of enumerated flags
*
* ### TODO: Write a detailed description for %Flags.
*/
template <typename E>
class PCL_CLASS Flags
{
public:
static_assert( sizeof( E ) <= sizeof( int ),
"Invalid sizeof( Flags::enum_type ): Must not be larger than sizeof( int )" );
/*!
* Represents the enumerated type that defines individual flags.
*/
typedef E enum_type;
/*!
* Represents the integral type used to store flags.
*/
typedef typename FlagType<std::is_unsigned<enum_type>::value>::type
flag_type;
/*!
* Constructs an empty (zero) %Flags instance.
*/
Flags() = default;
/*!
* Constructs a %Flags instance from an enumerated flag value \a e.
*/
constexpr
Flags( enum_type e )
: m_flags( int( e ) )
{
}
/*!
* Constructs a %Flags instance from a mask \a m.
*/
constexpr
Flags( flag_type m )
: m_flags( int( m ) )
{
}
/*!
* Copy constructor.
*/
Flags( const Flags& ) = default;
/*!
* Copy assignment operator. Returns a reference to this object.
*/
Flags& operator =( const Flags& ) = default;
/*!
* Assigns an enumerated flag value \a e to this object. Returns a reference
* to this object.
*/
Flags& operator =( enum_type e )
{
m_flags = e;
return *this;
}
/*!
* Performs a bitwise AND operation with other flags \a f and stores the
* resulting flags in this object. Returns a reference to this object.
*/
Flags& operator &=( Flags f )
{
m_flags &= f.m_flags;
return *this;
}
/*!
* Performs a bitwise AND operation with an enumerated flag value \a e and
* stores the resulting flags in this object. Returns a reference to this
* object.
*/
Flags& operator &=( enum_type e )
{
m_flags &= unsigned( e );
return *this;
}
/*!
* Performs a bitwise AND operation with a mask value \a m and stores the
* resulting flags in this object. Returns a reference to this object.
*/
Flags& operator &=( unsigned m )
{
m_flags &= m;
return *this;
}
/*!
* Performs a bitwise inclusive OR operation with other flags \a f and
* stores the resulting flags in this object. Returns a reference to this
* object.
*/
Flags& operator |=( Flags f )
{
m_flags |= f.m_flags;
return *this;
}
/*!
* Performs a bitwise inclusive OR operation with an enumerated flag value
* \a e and stores the resulting flags in this object. Returns a reference
* to this object.
*/
Flags& operator |=( enum_type e )
{
m_flags |= unsigned( e );
return *this;
}
/*!
* Performs a bitwise inclusive OR operation with a mask value \a m and
* stores the resulting flags in this object. Returns a reference to this
* object.
*/
Flags& operator |=( unsigned m )
{
m_flags |= m;
return *this;
}
/*!
* Performs a bitwise exclusive OR (XOR) operation with other flags \a f and
* stores the resulting flags in this object. Returns a reference to this
* object.
*/
Flags& operator ^=( Flags f )
{
m_flags ^= f.m_flags;
return *this;
}
/*!
* Performs a bitwise exclusive OR (XOR) operation with an enumerated flag
* value \a e and stores the resulting flags in this object. Returns a
* reference to this object.
*/
Flags& operator ^=( enum_type e )
{
m_flags ^= unsigned( e );
return *this;
}
/*!
* Performs a bitwise exclusive OR (XOR) operation with a mask value \a m
* and stores the resulting flags in this object. Returns a reference to
* this object.
*/
Flags& operator ^=( unsigned m )
{
m_flags ^= m;
return *this;
}
/*!
* Returns true iff the specified flag \a e is set in this %Flags object.
*/
constexpr bool IsFlagSet( enum_type e ) const
{
return (m_flags & e) != flag_type( 0 );
}
/*!
* Sets or clears the specified flag \a e in this %Flags object.
*/
void SetFlag( enum_type e, bool on = true )
{
if ( on )
m_flags |= e;
else
m_flags &= ~e;
}
/*!
* Clears the specified flag \a e.
* This is a convenience member function, equivalent to SetFlag( e, false ).
*/
void ClearFlag( enum_type e )
{
SetFlag( e, false );
}
/*!
* Clears all flags in this object.
*/
void Clear()
{
m_flags = flag_type( 0 );
}
/*!
* Sets the specified flag \a e in this object. Returns a reference to this
* object.
*/
Flags& operator <<( enum_type e )
{
SetFlag( e );
return *this;
}
/*!
* Returns true iff all flags in this object are zero.
*/
constexpr bool operator !() const
{
return m_flags == flag_type( 0 );
}
/*!
* Converts this %Flags object to an integer.
*/
constexpr operator flag_type() const
{
return m_flags;
}
/*!
* Returns a %Flags object whose value is the bitwise negation of the flags
* stored in this object.
*/
constexpr Flags operator ~() const
{
return Flags( enum_type( ~m_flags ) );
}
/*!
* Bitwise AND between two %Flags objects.
*/
constexpr Flags operator &( Flags f ) const
{
return Flags( enum_type( m_flags & f.m_flags ) );
}
/*!
* Bitwise AND between a Flags object and an enumerated value.
*/
constexpr Flags operator &( enum_type e ) const
{
return Flags( enum_type( m_flags & flag_type( e ) ) );
}
/*!
* Bitwise AND between a %Flags object and a mask.
*/
constexpr Flags operator &( unsigned m ) const
{
return Flags( enum_type( m_flags & m ) );
}
/*!
* Bitwise OR between two %Flags objects.
*/
constexpr Flags operator |( Flags f ) const
{
return Flags( enum_type( m_flags | f.m_flags ) );
}
/*!
* Bitwise OR between a Flags object and an enumerated value.
*/
constexpr Flags operator |( enum_type e ) const
{
return Flags( enum_type( m_flags | flag_type( e ) ) );
}
/*!
* Bitwise OR between a %Flags object and a mask.
*/
constexpr Flags operator |( unsigned m ) const
{
return Flags( enum_type( m_flags | m ) );
}
/*!
* Bitwise XOR between two %Flags objects.
*/
constexpr Flags operator ^( Flags f ) const
{
return Flags( enum_type( m_flags ^ f.m_flags ) );
}
/*!
* Bitwise XOR between a Flags object and an enumerated value.
*/
constexpr Flags operator ^( enum_type e ) const
{
return Flags( enum_type( m_flags ^ flag_type( e ) ) );
}
/*!
* Bitwise XOR between a %Flags object and a mask.
*/
constexpr Flags operator ^( unsigned m ) const
{
return Flags( enum_type( m_flags ^ m ) );
}
private:
flag_type m_flags = flag_type( 0 );
#ifndef __PCL_NO_FLAGS_SETTINGS_IO
friend class Settings;
#endif
#ifndef __PCL_NO_FLAGS_FILE_IO
friend class File;
#endif
#ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
friend class pi::GlobalSettings;
#endif
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_Flags_h
// ----------------------------------------------------------------------------
// EOF pcl/Flags.h - Released 2022-03-12T18:59:29Z
-547
View File
@@ -1,547 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Font.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Font_h
#define __PCL_Font_h
/// \file pcl/Font.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/Rectangle.h>
#include <pcl/StringList.h>
#include <pcl/UIObject.h>
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::FontFamily
* \brief Platform-independent, standard font families
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>FontFamily::Default</td> <td>Default font</td></tr>
* <tr><td>FontFamily::SansSerif</td> <td>Sans serif font: Helvetica, Swiss, Arial</td></tr>
* <tr><td>FontFamily::Helvetica</td> <td>Equivalent to SansSerif</td></tr>
* <tr><td>FontFamily::Swiss</td> <td>Equivalent to SansSerif</td></tr>
* <tr><td>FontFamily::Serif</td> <td>Serif font: Times, Garamond</td></tr>
* <tr><td>FontFamily::Times</td> <td>Equivalent to Serif</td></tr>
* <tr><td>FontFamily::Script</td> <td>Handwriting font: Script, Comic</td></tr>
* <tr><td>FontFamily::Monospace</td> <td>Fixed-pitch font: Courier, Vera Sans Mono</td></tr>
* <tr><td>FontFamily::TypeWriter</td> <td>Equivalent to Monospace</td></tr>
* <tr><td>FontFamily::Courier</td> <td>Equivalent to Monospace</td></tr>
* <tr><td>FontFamily::Teletype</td> <td>Equivalent to Monospace</td></tr>
* <tr><td>FontFamily::Decorative</td> <td>Decorative font: OldEnglish</td></tr>
* <tr><td>FontFamily::OldEnglish</td> <td>Equivalent to Decorative</td></tr>
* <tr><td>FontFamily::Symbol</td> <td>Math, greek, etc: Symbol</td></tr>
* </table>
*/
namespace FontFamily
{
enum value_type
{
Default, // default font
SansSerif, // sans serif font: Helvetica, Swiss, Arial
Helvetica = SansSerif,
Swiss = SansSerif,
Serif, // serif font: Times, Garamond
Times = Serif,
Script, // handwriting font: Script, Comic
Monospace, // fixed-pitch font: Courier, Vera Sans Mono
TypeWriter = Monospace,
Courier = Monospace,
Teletype = Monospace,
Decorative, // decorative font: OldEnglish,
OldEnglish = Decorative,
Symbol // math, greek, etc.: Symbol
};
String PCL_FUNC FamilyToFace( value_type family );
}
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::FontWeight
* \brief Standard font weights
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>FontWeight::Thin</td> <td>100</td></tr>
* <tr><td>FontWeight::ExtraLight</td> <td>200</td></tr>
* <tr><td>FontWeight::UltraLight</td> <td>= ExtraLight</td></tr>
* <tr><td>FontWeight::Light</td> <td>300</td></tr>
* <tr><td>FontWeight::Normal</td> <td>400</td></tr>
* <tr><td>FontWeight::Regular</td> <td>= Normal</td></tr>
* <tr><td>FontWeight::Medium</td> <td>500</td></tr>
* <tr><td>FontWeight::SemiBold</td> <td>600</td></tr>
* <tr><td>FontWeight::DemiBold</td> <td>= SemiBold</td></tr>
* <tr><td>FontWeight::Bold</td> <td>700</td></tr>
* <tr><td>FontWeight::ExtraBold</td> <td>800</td></tr>
* <tr><td>FontWeight::UltraBold</td> <td>= ExtraBold</td></tr>
* <tr><td>FontWeight::Heavy</td> <td>850</td></tr>
* <tr><td>FontWeight::Black</td> <td>900</td></tr>
* </table>
*/
namespace FontWeight
{
enum value_type
{
Thin = 100,
ExtraLight = 200,
UltraLight = ExtraLight,
Light = 300,
Normal = 400,
Regular = Normal,
Medium = 500,
SemiBold = 600,
DemiBold = SemiBold,
Bold = 700,
ExtraBold = 800,
UltraBold = ExtraBold,
Heavy = 850,
Black = 900
};
}
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::FontStretch
* \brief Standard font stretchs
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>FontStretch::UltraCondensed</td> <td>50</td></tr>
* <tr><td>FontStretch::ExtraCondensed</td> <td>62</td></tr>
* <tr><td>FontStretch::Condensed</td> <td>75</td></tr>
* <tr><td>FontStretch::SemiCondensed</td> <td>87</td></tr>
* <tr><td>FontStretch::Unstretched</td> <td>100</td></tr>
* <tr><td>FontStretch::SemiExpanded</td> <td>112</td></tr>
* <tr><td>FontStretch::Expanded</td> <td>125</td></tr>
* <tr><td>FontStretch::ExtraExpanded</td> <td>150</td></tr>
* <tr><td>FontStretch::UltraExpanded</td> <td>200</td></tr>
* </table>
*/
namespace FontStretch
{
enum value_type
{
UltraCondensed = 50,
ExtraCondensed = 62,
Condensed = 75,
SemiCondensed = 87,
Unstretched = 100,
SemiExpanded = 112,
Expanded = 125,
ExtraExpanded = 150,
UltraExpanded = 200
};
}
// ----------------------------------------------------------------------------
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
// ----------------------------------------------------------------------------
/*!
* \class Font
* \brief Client-side interface to a PixInsight %Font object
*
* ### TODO: Write a detailed description for %Font.
*/
class PCL_CLASS Font : public UIObject
{
public:
/*!
* Represents a standard font family.
*/
typedef FontFamily::value_type family;
/*!
* Represents a standard font weight.
*/
typedef FontWeight::value_type std_weight;
/*!
* Represents a standard font stretch.
*/
typedef FontStretch::value_type std_stretch;
/*!
* Constructs a %Font object with the specified family and \a size in
* points.
*
* ### TODO: Elaborate on font families, font matching, etc.
*/
Font( family f = FontFamily::Default, double size = 12.0 );
/*!
* Constructs a %Font object with the specified font \a face and \a size
* in points.
*
* ### TODO: Elaborate on font faces, font matching, etc.
*/
Font( const String& face, double size = 12.0 );
/*!
* Copy constructor. This object will reference the same server-side font
* as the specified instance \a f.
*/
Font( const Font& f ) : UIObject( f )
{
}
/*!
* Move constructor.
*/
Font( Font&& x ) : UIObject( std::move( x ) )
{
}
/*!
* Destroys a %Font object. If this object references an existing font in
* the PixInsight core application, its reference count is decremented. If
* it becomes unreferenced, it will be garbage-collected.
*/
virtual ~Font()
{
}
/*!
* Copy assignment operator. Returns a reference to this object.
*
* Makes this object reference the same server-side font as the specified
* instance \a f. If the previous font becomes unreferenced, it will be
* garbage-collected by the PixInsight core application.
*/
Font& operator =( const Font& f )
{
SetHandle( f.handle );
return *this;
}
/*!
* Move assignment operator. Returns a reference to this object.
*/
Font& operator =( Font&& x )
{
Transfer( x );
return *this;
}
/*!
* Returns a reference to a <em>null font</em>. A null %Font object does not
* correspond to an existing font object in the PixInsight core application.
*/
static Font& Null();
/*! #
*/
String Face() const;
/*! #
*/
void SetFace( const String& );
/*! #
*/
bool IsExactMatch() const;
/*! #
*/
StringList AvailableWritingSystems() const
{
return AvailableFontWritingSystems( Face() );
}
/*! #
*/
StringList AvailableStyles() const
{
return AvailableFontStyles( Face() );
}
/*! #
*/
bool IsScalable( const String& style = String() ) const
{
return IsScalableFont( Face(), style );
}
/*! #
*/
Array<double> OptimalPointSizes( const String& style = String() ) const
{
return OptimalFontPointSizes( Face(), style );
}
/*! #
*/
int PixelSize() const;
/*! #
*/
void SetPixelSize ( int );
/*! #
*/
double PointSize() const;
/*! #
*/
void SetPointSize( double );
/*! #
*/
bool IsFixedPitch() const;
/*! #
*/
bool IsFixedPitch( const String& style ) const
{
return IsFixedPitchFont( Face(), style );
}
/*! #
*/
void SetFixedPitch( bool = true );
/*! #
*/
bool IsKerningEnabled() const;
/*! #
*/
void EnableKerning( bool = true );
/*! #
*/
void DisableKerning( bool = true );
/*! #
*/
int StretchFactor() const;
/*! #
*/
void SetStretchFactor( int );
/*! #
*/
int Weight() const;
/*! #
*/
int Weight( const String& style ) const
{
return FontWeight( Face(), style );
}
/*! #
*/
void SetWeight( int );
/*! #
*/
bool IsBold() const
{
return Weight() >= FontWeight::Bold;
}
/*! #
*/
void SetBold( bool b = true )
{
SetWeight( b ? FontWeight::Bold : FontWeight::Normal );
}
/*! #
*/
bool IsItalic() const;
/*! #
*/
bool IsItalic( const String& style ) const
{
return IsItalicFont( Face(), style );
}
/*! #
*/
void SetItalic( bool = true );
/*! #
*/
bool IsUnderline() const;
/*! #
*/
void SetUnderline( bool = true );
/*! #
*/
bool IsOverline() const;
/*! #
*/
void SetOverline( bool = true );
/*! #
*/
bool IsStrikeOut() const;
/*! #
*/
void SetStrikeOut( bool = true );
/*! #
*/
int Ascent() const;
/*! #
*/
int Descent() const;
/*! #
*/
int Height() const;
/*! #
*/
int LineSpacing() const;
/*! #
*/
bool IsCharDefined( int ) const;
/*! #
*/
int MaxWidth() const;
/*! #
*/
int Width( const String& ) const;
/*! #
*/
int Width( int ch ) const;
/*! #
*/
Rect BoundingRect( const String& ) const;
/*! #
*/
Rect TightBoundingRect( const String& ) const;
/*! #
*/
static StringList AvailableFonts( const String& writingSystem = String() );
/*! #
*/
static StringList AvailableFontWritingSystems( const String& font );
/*! #
*/
static StringList AvailableFontStyles( const String& font );
/*! #
*/
static Array<double> OptimalFontPointSizes( const String& font, const String& style = String() );
/*! #
*/
static bool IsScalableFont( const String& font, const String& style = String() );
/*! #
*/
static bool IsFixedPitchFont( const String& font, const String& style = String() );
/*! #
*/
static bool IsItalicFont( const String& font, const String& style = String() );
/*! #
*/
static int FontWeight( const String& font, const String& style = String() );
private:
Font( void* h ) : UIObject( h )
{
}
void* CloneHandle() const override;
friend class InternalFontEnumerator;
friend class GraphicsContextBase;
friend class Control;
friend class TreeBox;
};
// ----------------------------------------------------------------------------
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
} // pcl
#endif // __PCL_Font_h
// ----------------------------------------------------------------------------
// EOF pcl/Font.h - Released 2022-03-12T18:59:29Z
-393
View File
@@ -1,393 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/FontComboBox.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_FontComboBox_h
#define __PCL_FontComboBox_h
/// \file pcl/FontComboBox.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/AutoPointer.h>
#include <pcl/ComboBox.h>
#include <pcl/Font.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class FontComboBox
* \brief A %ComboBox descendant class to select font faces.
*
* %FontComboBox is a utility class that provides a simple list with all the
* installed fonts on the system, plus the set of <em>standard font
* families</em> - see the FontFamily namespace for the supported set of
* standard font families in the PixInsight/PCL platform.
*
* Optionally, %FontComboBox can restrict the list of font items to include
* only scalable, bitmapped or fixed-pitch fonts. The fonts list can also be
* restricted as a function of the available writing systems (Latin, Greek,
* Cyrillic, and so on).
*
* \sa Font, ComboBox, FontFamily
*/
class PCL_CLASS FontComboBox : public ComboBox
{
public:
/*!
* Constructs a %FontComboBox as a child control of \a parent.
*
* A default set of %ComboBox items is created for the full set of fonts
* currently installed on the system.
*/
FontComboBox( Control& parent = Control::Null() );
/*!
* Destroys a %FontComboBox control.
*/
virtual ~FontComboBox()
{
}
/*!
* Returns the face name of the font that corresponds to the currently
* selected %ComboBox item, or an empty string if no item is currently
* selected.
*
* \sa CurrentFont(), SetCurrentFont( const String& ),
* SetCurrentFont( const Font& )
*/
String CurrentFontFace() const;
/*!
* Returns a Font object that corresponds to the currently selected
* %ComboBox item, or a null font object (Font::Null()) if no item is
* currently selected.
*
* \param size The size in points of the returned font.
*
* This is a convenience member function, equivalent to:
* Font( CurrentFontFace(), size ).
*
* \sa CurrentFontFace(), SetCurrentFont( const String& ),
* SetCurrentFont( const Font& )
*/
pcl::Font CurrentFont( double size = 12.0 ) const
{
return pcl::Font( CurrentFontFace(), size );
}
/*!
* Selects the %ComboBox item corresponding to the specified font \a face.
*
* If the specified \a face doesn't correspond to an installed or standard
* font family, or if an empty string is specified, this member function
* leaves the %ComboBox control with no selection, i.e. with its selected
* index equal to -1.
*
* \sa SetCurrentFont( const Font& ), CurrentFont(), CurrentFontFace()
*/
void SetCurrentFont( const String& face );
/*!
* Selects the %ComboBox item corresponding to the specified \a font.
*
* If the specified \a font doesn't correspond to an installed or standard
* font family, or if \a font is Font::Null(), this member function leaves
* the %ComboBox control with no selection, i.e. with its selected index
* equal to -1.
*
* This is a convenience member function, equivalent to:
* SetCurrentFont( font.Face() ).
*
* \sa SetCurrentFont( const String& ), CurrentFont(), CurrentFontFace()
*/
void SetCurrentFont( const pcl::Font& font )
{
SetCurrentFont( font.Face() );
}
/*!
* Resets this %FontComboBox control to its default state: Replaces the
* current list of %ComboBox items with a new set corresponding to the
* standard font families available on the PixInsight/PCL platform, plus all
* installed fonts on the system.
*
* \sa AddStandardFontFamilies(), AddScalableFonts(), AddFixedPitchFonts(),
* AddItalicFonts(), AddWritingSystem()
*/
void ResetFonts();
/*!
* Adds a list of %ComboBox items corresponding to the standard font
* families available on the PixInsight/PCL platform. This includes the
* following fonts: Default, SansSerif, Serif, Script, Monospace,
* Decorative, and Symbol.
*
* \note The list of standard font families is always prepended at the
* beginning of the existing set of items.
*
* \sa RemoveStandardFontFamilies()
*/
void AddStandardFontFamilies();
/*!
* Removes all existing %ComboBox items that correspond to standard font
* families available on the PixInsight/PCL platform. See
* AddStandardFontFamilies() for more information.
*
* \sa AddStandardFontFamilies()
*/
void RemoveStandardFontFamilies();
/*!
* Adds a list of %ComboBox items corresponding to all scalable fonts
* currently installed on the system.
*
* \sa RemoveScalableFonts()
*/
void AddScalableFonts();
/*!
* Removes all existing %ComboBox items that correspond to scalable fonts.
*
* \sa AddScalableFonts()
*/
void RemoveScalableFonts();
/*!
* Adds a list of %ComboBox items corresponding to all fixed-pitch fonts
* currently installed on the system.
*
* \sa RemoveFixedPitchFonts()
*/
void AddFixedPitchFonts();
/*!
* Removes all existing %ComboBox items that correspond to fixed-pitch
* fonts.
*
* \sa AddFixedPitchFonts()
*/
void RemoveFixedPitchFonts();
/*!
* Adds a list of %ComboBox items corresponding to all italic fonts
* currently installed on the system.
*
* \sa RemoveItalicFonts()
*/
void AddItalicFonts();
/*!
* Removes all existing %ComboBox items that correspond to italic fonts.
*
* \sa AddItalicFonts()
*/
void RemoveItalicFonts();
/*!
* Adds a list of %ComboBox items corresponding to all installed fonts that
* support the specified writing system.
*
* \sa RemoveWritingSystem()
*/
void AddWritingSystem( const String& writingSystem );
/*!
* Removes all existing %ComboBox items that correspond to installed fonts
* supporting the specified writing system.
*
* \sa AddWritingSystem()
*/
void RemoveWritingSystem( const String& writingSystem );
/*!
* Adds items for all installed fonts that support the Latin writing system.
*
* This is a convenience member function, equivalent to:
* AddWritingSystem( "Latin" ).
*
* \sa RemoveLatinFonts(), AddGreekFonts()
*/
void AddLatinFonts()
{
AddWritingSystem( "Latin" );
}
/*!
* Removes all existing %ComboBox items that correspond to installed fonts
* supporting the Latin writing system.
*
* \sa AddLatinFonts(), RemoveGreekFonts()
*/
void RemoveLatinFonts()
{
RemoveWritingSystem( "Latin" );
}
/*!
* Adds items for all installed fonts that support the Greek writing system.
*
* This is a convenience member function, equivalent to:
* AddWritingSystem( "Greek" ).
*
* \sa RemoveGreekFonts(), AddLatinFonts()
*/
void AddGreekFonts()
{
AddWritingSystem( "Greek" );
}
/*!
* Removes all existing %ComboBox items that correspond to installed fonts
* supporting the Greek writing system.
*
* \sa AddGreekFonts(), RemoveLatinFonts()
*/
void RemoveGreekFonts()
{
RemoveWritingSystem( "Greek" );
}
// -------------------------------------------------------------------------
// Event handlers
//
// void OnFontSelected( FontComboBox& sender, const String& font );
// void OnFontHighlighted( FontComboBox& sender, const String& font );
/*!
* \defgroup fontcombobox_event_handlers FontComboBox Event Handlers
*/
/*!
* Defines the prototype of a <em>font combo box event handler</em>.
*
* A font combo box event is generated when an item is selected or
* highlighted in a font combo box.
*
* \param sender The %FontComboBox control that sends a font combo box
* event.
*
* \param font The face name of the font that has been selected or
* highlighted in the \a sender font combo box.
*
* \ingroup fontcombobox_event_handlers
*/
typedef void (Control::*font_event_handler)( FontComboBox& sender, const String& font );
/*!
* Sets the <em>font selected</em> event handler for this font combo box.
*
* \param handler The font combo box event handler. Must be a member
* function of the receiver object's class. This handler
* will be called whenever a font is selected in this
* font combo box control.
*
* \param receiver The control that will receive <em>font selected</em>
* events from this font combo box.
*
* \ingroup fontcombobox_event_handlers
*/
void OnFontSelected( font_event_handler handler, Control& receiver );
/*!
* Sets the <em>font highlighted</em> event handler for this font combo
* box control.
*
* \param handler The font combo box event handler. Must be a member
* function of the receiver object's class. This handler
* will be called whenever a font is highlighted in this
* font combo box control.
*
* \param receiver The control that will receive <em>font
* highlighted</em> events from this font combo box.
*
* \ingroup fontcombobox_event_handlers
*/
void OnFontHighlighted( font_event_handler handler, Control& receiver );
private:
struct EventHandlers
{
font_event_handler onFontSelected = nullptr;
Control* onFontSelectedReceiver = nullptr;
font_event_handler onFontHighlighted = nullptr;
Control* onFontHighlightedReceiver = nullptr;
EventHandlers() = default;
EventHandlers( const EventHandlers& ) = default;
EventHandlers& operator =( const EventHandlers& ) = default;
};
AutoPointer<EventHandlers> m_handlers;
void ItemSelected( ComboBox&, int );
void ItemHighlighted( ComboBox&, int );
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
#endif // __PCL_FontComboBox_h
// ----------------------------------------------------------------------------
// EOF pcl/FontComboBox.h - Released 2022-03-12T18:59:29Z
-386
View File
@@ -1,386 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/FourierTransform.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_FourierTransform_h
#define __PCL_FourierTransform_h
/// \file pcl/FourierTransform.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/FFT1D.h>
#include <pcl/FFT2D.h>
#include <pcl/ImageTransformation.h>
#include <pcl/ParallelProcess.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::FFTDirection
* \brief Defines directions and types of fast Fourier transforms.
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>FFTDirection::Forward</td> <td>Fourier transform</td></tr>
* <tr><td>FFTDirection::Backward</td> <td>Inverse Fourier transform</td></tr>
* </table>
*/
namespace FFTDirection
{
enum value_type
{
Forward,
Backward
};
}
// ----------------------------------------------------------------------------
/*!
* \class InPlaceFourierTransform
* \brief In-place discrete Fourier transform of two-dimensional complex images.
*
* %InPlaceFourierTransform performs in-place, discrete Fourier transforms of
* complex-sampled two-dimensional images using fast Fourier transform
* algorithms.
*
* %InPlaceFourierTransform can only be applied to 32-bit and 64-bit floating
* point complex images: either ComplexImage or DComplexImage.
*
* \note \b Important - For performance reasons, %InPlaceFourierTransform can
* change the dimensions of a transformed image (width and/or height in pixels)
* to their nearest optimized %FFT lengths. This may involve reallocation of
* pixel data. If the transformed image already has optimized dimensions, no
* size change or reallocation occurs. See the GenericFFT::GenericFFT( int )
* constructor for details on optimized %FFT lengths.
*
* \sa FourierTransform
*/
class PCL_CLASS InPlaceFourierTransform : public ImageTransformation, public ParallelProcess
{
public:
/*!
* Represents a %FFT direction and type.
*/
typedef FFTDirection::value_type transform_type;
/*!
* Constructs an %InPlaceFourierTransform instance.
*
* \param type Transform direction and type. This parameter can have one of
* the following values:\n
* \n
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>FFTDirection::Forward</td>
* <td>Fourier transform. This is the default value.</td></tr>
* <tr><td>FFTDirection::Backward</td>
* <td>Inverse Fourier transform</td></tr>
* </table>
*/
InPlaceFourierTransform( transform_type type = FFTDirection::Forward )
: m_type( type )
{
}
/*!
* Copy constructor.
*/
InPlaceFourierTransform( const InPlaceFourierTransform& ) = default;
/*!
* Destroys this %InPlaceFourierTransform object.
*/
virtual ~InPlaceFourierTransform()
{
}
/*!
* Returns the type and direction of this Fourier transform. See the
* FFTDirection namespace for possible values.
*/
transform_type Type() const
{
return m_type;
}
protected:
transform_type m_type;
// In-place FFT of complex images.
void Apply( pcl::ComplexImage& ) const override;
void Apply( pcl::DComplexImage& ) const override;
};
// ----------------------------------------------------------------------------
/*!
* \class InPlaceInverseFourierTransform
* \brief In-place discrete inverse Fourier transform of two-dimensional complex images.
*
* %InPlaceInverseFourierTransform performs in-place, inverse discrete Fourier
* transforms of complex-sampled two-dimensional images using fast Fourier
* transform algorithms.
*
* This is a convenience class derived from InPlaceFourierTransform. It
* implements exactly the same functions as its parent class, but performs
* inverse Fourier transforms by default.
*
* \sa InPlaceFourierTransform
*/
class PCL_CLASS InPlaceInverseFourierTransform : public InPlaceFourierTransform
{
public:
/*!
* Constructs an %InPlaceInverseFourierTransform instance.
*/
InPlaceInverseFourierTransform()
: InPlaceFourierTransform( FFTDirection::Backward )
{
}
/*!
* Copy constructor.
*/
InPlaceInverseFourierTransform( const InPlaceInverseFourierTransform& ) = default;
/*!
* Virtual destructor.
*/
virtual ~InPlaceInverseFourierTransform()
{
}
};
// ----------------------------------------------------------------------------
/*!
* \class FourierTransform
* \brief Out-of-place discrete Fourier transform of two-dimensional images.
*
* %FourierTransform performs out-of-place, discrete Fourier transforms of
* complex and real two-dimensional images, using fast Fourier transform
* algorithms.
*
* %FourierTransform stores a Fourier transform as either a ComplexImage
* (32-bit floating point) or a DComplexImage (64-bit floating point). The
* transform image is transported by an ImageVariant object. 64-bit transforms
* are created for 64-bit floating point (both real and complex) and 32-bit
* integer (real) images. For the rest of images a 32-bit transform is used.
*
* \sa InPlaceFourierTransform
*/
class PCL_CLASS FourierTransform : public BidirectionalImageTransformation, public ParallelProcess
{
public:
/*!
* Default constructor.
*
* Creates a %FourierTransform object with an empty Fourier transform.
*/
FourierTransform() = default;
/*!
* Copy constructor.
*
* This constructor copies the Fourier transform in the specified source
* object. The Fourier transform is an ImageVariant object. This constructor
* creates an %ImageVariant that references the same image as the source
* object.
*/
FourierTransform( const FourierTransform& ) = default;
/*!
* Move constructor.
*/
FourierTransform( FourierTransform&& ) = default;
/*!
* Destroys this %FourierTransform object.
*
* The current Fourier transform, if it exists, is automatically released.
* The Fourier transform is implemented as an ImageVariant object. If there
* are no external references to the image transported by the %ImageVariant,
* then it is also destroyed and deallocated.
*/
virtual ~FourierTransform()
{
}
/*!
* Copy assignment operator. Returns a reference to this object.
*
* This operator copies the Fourier transform in the source object. The
* Fourier transform is an ImageVariant object. This operator causes the
* %ImageVariant in this object to reference the same image as the source
* object. If this object already stores a Fourier transform, it is released
* before assignment.
*/
FourierTransform& operator =( const FourierTransform& ) = default;
/*!
* Move assignment operator. Returns a reference to this object.
*/
FourierTransform& operator =( FourierTransform&& ) = default;
/*!
* Returns a constant reference to the Fourier transform in this
* %FourierTransform object.
*
* The Fourier transform is an ImageVariant object. It can transport either
* a 32-bit (float) or 64-bit (double) complex image, that is, either a
* ComplexImage or a DComplexImage, depending on the sample type of the
* transformed image.
*/
const ImageVariant& DFT() const
{
return m_dft;
}
/*!
* Returns a reference to the Fourier transform in this %FourierTransform
* object.
*
* The Fourier transform is an ImageVariant object. It can transport either
* a 32-bit (float) or 64-bit (double) complex image, that is, either a
* ComplexImage or a DComplexImage, depending on the sample type of the
* transformed image.
*/
ImageVariant& DFT()
{
return m_dft;
}
/*!
* A synonym for DFT() const.
*/
const ImageVariant& operator *() const
{
return DFT();
}
/*!
* A synonym for DFT().
*/
ImageVariant& operator *()
{
return DFT();
}
/*!
* Transfers ownership of the current Fourier transform to the caller.
*
* Returns a copy of the ImageVariant object that transports the current
* Fourier transform in this object. Then the internal ImageVariant of this
* object is released. The transform itself, which is either a ComplexImage
* or a DComplexImage, will not be destroyed, as the newly created
* %ImageVariant will transport and reference it.
*
* If this object stores no Fourier transform, the returned %ImageVariant
* will be empty (no image transported).
*/
ImageVariant ReleaseTransform()
{
ImageVariant r;
m_dft.ReleaseTo( r );
return r;
}
/*!
* Releases the current Fourier transform, if exists.
*
* If there are no external references to the image transported by the
* internal ImageVariant object, then the transform matrix, which is either
* a ComplexImage or a DComplexImage object, is destroyed.
*/
void Clear()
{
m_dft.Free();
}
protected:
// Discrete 2-D Fourier Transform
ImageVariant m_dft;
// Transform
void Transform( const pcl::Image& ) override;
void Transform( const pcl::DImage& ) override;
void Transform( const pcl::ComplexImage& ) override;
void Transform( const pcl::DComplexImage& ) override;
void Transform( const pcl::UInt8Image& ) override;
void Transform( const pcl::UInt16Image& ) override;
void Transform( const pcl::UInt32Image& ) override;
// Inverse transform
void Apply( pcl::Image& ) const override;
void Apply( pcl::DImage& ) const override;
void Apply( pcl::ComplexImage& ) const override;
void Apply( pcl::DComplexImage& ) const override;
void Apply( pcl::UInt8Image& ) const override;
void Apply( pcl::UInt16Image& ) const override;
void Apply( pcl::UInt32Image& ) const override;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_FourierTransform_h
// ----------------------------------------------------------------------------
// EOF pcl/FourierTransform.h - Released 2022-03-12T18:59:29Z
-195
View File
@@ -1,195 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Frame.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Frame_h
#define __PCL_Frame_h
/// \file pcl/Frame.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/Control.h>
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::FrameStyle
* \brief Frame styles
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>FrameStyle::Flat</td> <td>No frame is drawn</td></tr>
* <tr><td>FrameStyle::Box</td> <td>Simple rectangular frame</td></tr>
* <tr><td>FrameStyle::Raised</td> <td>Raised 3-D panel</td></tr>
* <tr><td>FrameStyle::Sunken</td> <td>Sunken (lowered) 3-D panel</td></tr>
* <tr><td>FrameStyle::Styled</td> <td>The appearance depends on the current platform and GUI style</td></tr>
* </table>
*/
namespace FrameStyle
{
enum value_type
{
Flat, // No frame is drawn
Box, // Simple rectangular frame
Raised, // Raised 3-D panel
Sunken, // Sunken (lowered) 3-D panel
Styled // The appearance depends on the current platform and GUI style
};
}
// ----------------------------------------------------------------------------
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
// ----------------------------------------------------------------------------
/*!
* \class Frame
* \brief Client-side interface to a PixInsight %Frame control
*
* ### TODO: Write a detailed description for %Frame.
*/
class PCL_CLASS Frame : public Control
{
public:
/*!
* Represents a frame style.
*/
typedef FrameStyle::value_type style;
/*!
* Constructs a %Frame as a child control of \a parent.
*/
Frame( Control& parent = Control::Null() );
/*!
* Destroys a %Frame object.
*/
virtual ~Frame()
{
}
/*!
* Returns the current frame style.
*/
style Style() const;
/*!
* Sets the frame style.
*/
void SetStyle( style );
/*!
* Returns the current frame's line width in pixels.
*/
int LineWidth() const;
/*!
* Sets the frame's line width in pixels.
*/
void SetLineWidth( int );
/*!
* Returns the border width of this frame.
*
* The border width is the distance in pixels from the outer frame rectangle
* to the inner client rectangle.
*/
int BorderWidth() const;
/*! #
*/
int ScaledLineWidth() const
{
return PhysicalPixelsToLogical( LineWidth() );
}
/*! #
*/
void SetScaledLineWidth( int width )
{
SetLineWidth( LogicalPixelsToPhysical( width ) );
}
/*! #
*/
int ScaledBorderWidth() const
{
return PhysicalPixelsToLogical( BorderWidth() );
}
protected:
/*!
* \internal
*/
Frame( void* h ) : Control( h )
{
}
};
// ----------------------------------------------------------------------------
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
} // pcl
#endif // __PCL_Frame_h
// ----------------------------------------------------------------------------
// EOF pcl/Frame.h - Released 2022-03-12T18:59:29Z
-483
View File
@@ -1,483 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/GaiaDatabaseFile.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_GaiaDatabaseFile_h
#define __PCL_GaiaDatabaseFile_h
/// \file pcl/GaiaDatabaseFile.h
#include <pcl/Defs.h>
#include <pcl/ElapsedTime.h>
#include <pcl/Flags.h>
#include <pcl/StarDatabaseFile.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::GaiaStarFlag
* \brief Data availability and quality flags for Gaia star data.
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>GaiaStarFlag::NoPM</td> <td>No proper motions and parallax available.</td></tr>
* <tr><td>GaiaStarFlag::NoGBPMag</td> <td>No G-BP magnitude available.</td></tr>
* <tr><td>GaiaStarFlag::NoGRPMag</td> <td>No G-RP magnitude available.</td></tr>
* <tr><td>GaiaStarFlag::LackingData</td> <td>Equivalent to NoPM|NoGBPMag|NoGRPMag.</td></tr>
* <tr><td>GaiaStarFlag::GoldRA</td> <td>Standard error of right ascension &lt; 0.13 mas.</td></tr>
* <tr><td>GaiaStarFlag::GoldDec</td> <td>Standard error of declination &lt; 0.12 mas.</td></tr>
* <tr><td>GaiaStarFlag::GoldParx</td> <td>Standard error of parallax &lt; 0.13 mas.</td></tr>
* <tr><td>GaiaStarFlag::GoldPMRA</td> <td>Standard error of proper motion in right ascension &lt; 0.14 mas/year.</td></tr>
* <tr><td>GaiaStarFlag::GoldPMDec</td> <td>Standard error of proper motion in declination &lt; 0.12 mas/year.</td></tr>
* <tr><td>GaiaStarFlag::GoldAstrometry</td> <td>Equivalent to GoldRA|GoldDec|GoldParx|GoldPMRA|GoldPMDec.</td></tr>
* <tr><td>GaiaStarFlag::SilverRA</td> <td>Standard error of right ascension in the range [0.13,1.43) mas.</td></tr>
* <tr><td>GaiaStarFlag::SilverDec</td> <td>Standard error of declination in the range [0.12,1.28) mas.</td></tr>
* <tr><td>GaiaStarFlag::SilverParx</td> <td>Standard error of parallax in the range [0.13,0.86) mas.</td></tr>
* <tr><td>GaiaStarFlag::SilverPMRA</td> <td>Standard error of proper motion in right ascension in the range [0.14,0.97) mas/year.</td></tr>
* <tr><td>GaiaStarFlag::SilverPMDec</td> <td>Standard error of proper motion in declination in the range [0.12,0.85) mas/year.</td></tr>
* <tr><td>GaiaStarFlag::SilverAstrometry</td> <td>Equivalent to SilverRA|SilverDec|SilverParx|SilverPMRA|SilverPMDec.</td></tr>
* <tr><td>GaiaStarFlag::BronzeRA</td> <td>Standard error of right ascension in the range [1.43,2.49) mas.</td></tr>
* <tr><td>GaiaStarFlag::BronzeDec</td> <td>Standard error of declination in the range [1.28,2.22) mas.</td></tr>
* <tr><td>GaiaStarFlag::BronzeParx</td> <td>Standard error of parallax in the range [0.86,1.38) mas.</td></tr>
* <tr><td>GaiaStarFlag::BronzePMRA</td> <td>Standard error of proper motion in right ascension in the range [0.97,1.58) mas/year.</td></tr>
* <tr><td>GaiaStarFlag::BronzePMDec</td> <td>Standard error of proper motion in declination in the range [0.85,1.38) mas/year.</td></tr>
* <tr><td>GaiaStarFlag::BronzeAstrometry</td> <td>Equivalent to BronzeRA|BronzeDec|BronzeParx|BronzePMRA|BronzePMDec.</td></tr>
* <tr><td>GaiaStarFlag::GoldGMag</td> <td>Error on G-band mean flux < 0.84 e-/s.</td></tr>
* <tr><td>GaiaStarFlag::GoldGBPMag</td> <td>Error on the integrated BP mean flux < 4.94 e-/s.</td></tr>
* <tr><td>GaiaStarFlag::GoldGRPMag</td> <td>Error on the integrated RP mean flux < 5.89 e-/s.</td></tr>
* <tr><td>GaiaStarFlag::GoldPhotometry</td> <td>Equivalent to GoldGMag|GoldGBPMag|GoldGRPMag.</td></tr>
* <tr><td>GaiaStarFlag::SilverGMag</td> <td>Error on G-band mean flux in the range [0.84,2.13) e-/s.</td></tr>
* <tr><td>GaiaStarFlag::SilverGBPMag</td> <td>Error on the integrated BP mean flux in the range [4.94,12.61) e-/s.</td></tr>
* <tr><td>GaiaStarFlag::SilverGRPMag</td> <td>Error on the integrated RP mean flux in the range [5.89,15.40) e-/s.</td></tr>
* <tr><td>GaiaStarFlag::SilverPhotometry</td> <td>Equivalent to SilverGMag|SilverGBPMag|SilverGRPMag.</td></tr>
* <tr><td>GaiaStarFlag::BronzeGMag</td> <td>Error on G-band mean flux in the range [2.13,3.08) e-/s.</td></tr>
* <tr><td>GaiaStarFlag::BronzeGBPMag</td> <td>Error on the integrated BP mean flux in the range [12.61,18.04) e-/s.</td></tr>
* <tr><td>GaiaStarFlag::BronzeGRPMag</td> <td>Error on the integrated RP mean flux in the range [15.40,22.35) e-/s.</td></tr>
* <tr><td>GaiaStarFlag::BronzePhotometry</td> <td>Equivalent to BronzeGMag|BronzeGBPMag|BronzeGRPMag.</td></tr>
* <tr><td>GaiaStarFlag::BPRPExcess</td> <td>BP-RP excess factor &ge; 2.0</td></tr>
* <tr><td>GaiaStarFlag::BPRPExcessHigh</td> <td>BP-RP excess factor &ge; 5.0 (Gaia EDR3 only)</td></tr>
* </table>
*
* The above data quality ranges correspond to the Gaia EDR3 XPSD database
* version 1.0.0, released December 4, 2020.
*
* \ingroup point_source_databases
*/
namespace GaiaStarFlag
{
enum mask_type
{
NoPM = 0x00000001,
NoGBPMag = 0x00000002,
NoGRPMag = 0x00000004,
LackingData = 0x00000007,
GoldRA = 0x00000010,
GoldDec = 0x00000020,
GoldPMRA = 0x00000040,
GoldPMDec = 0x00000080,
SilverRA = 0x00000100,
SilverDec = 0x00000200,
SilverPMRA = 0x00000400,
SilverPMDec = 0x00000800,
BronzeRA = 0x00001000,
BronzeDec = 0x00002000,
BronzePMRA = 0x00004000,
BronzePMDec = 0x00008000,
GoldGMag = 0x00010000,
GoldGBPMag = 0x00020000,
GoldGRPMag = 0x00040000,
GoldParx = 0x00080000,
SilverGMag = 0x00100000,
SilverGBPMag = 0x00200000,
SilverGRPMag = 0x00400000,
SilverParx = 0x00800000,
BronzeGMag = 0x01000000,
BronzeGBPMag = 0x02000000,
BronzeGRPMag = 0x04000000,
BronzeParx = 0x08000000,
BPRPExcess = 0x10000008,
BPRPExcessHigh = 0x20000000,
GoldAstrometry = 0x000800F0,
SilverAstrometry = 0x00800F00,
BronzeAstrometry = 0x0800F000,
GoldPhotometry = 0x00070000,
SilverPhotometry = 0x00700000,
BronzePhotometry = 0x07000000
};
}
// ----------------------------------------------------------------------------
/*!
* \struct GaiaStarData
* \brief Star data structure for Gaia catalog search operations.
*
* \ingroup point_source_databases
*/
struct PCL_CLASS GaiaStarData
{
double ra = 0; //!< Right ascension in degrees, in the range [0,360).
double dec = 0; //!< Declination in degrees, in the range [-90,+90].
float parx = 0; //!< Parallax in mas.
float pmra = 0; //!< Proper motion in right ascension * cos(dec), in mas/year.
float pmdec = 0; //!< Proper motion in declination, in mas/year.
float magG = 0; //!< Mean G magnitude.
float magBP = 0; //!< Mean G_BP magnitude.
float magRP = 0; //!< Mean G_RP magnitude.
uint32 flags = 0u; //!< Data availability and quality flags. See the GaiaStarFlag namespace.
};
// ----------------------------------------------------------------------------
/*!
* \struct pcl::GaiaSearchData
* \brief Data items and parameters for Gaia catalog search operations.
*
* \ingroup point_source_databases
*/
typedef XPSD::SearchData<GaiaStarData> GaiaSearchData;
// ----------------------------------------------------------------------------
/*!
* \class GaiaDatabaseFile
* \brief Gaia catalog star database file (XPSD format).
*
* This class implements an interface to XPSD files serializing encoded Gaia
* star data. As of writing this documentation (December 2020), Gaia DR2 and
* EDR3 are supported and have been implemented.
*
* The most important functionality of this class is performing fast indexed
* search operations to retrieve point source data for Gaia stars matching a
* set of user-defined criteria. See the GaiaDatabaseFile::Search() member
* function and the GaiaSearchData structure for detailed information.
*
* This implementation provides the following data for the complete Gaia DR2
* and EDR3 catalogs:
*
* \li Source positions.
* \li Parallaxes.
* \li Proper motions.
* \li Mean magnitudes on the G, GBP and GRP bands.
* \li Data availability and quality flags.
*
* \b References
*
* \li Gaia Data Release 2 - online resources:
* https://www.cosmos.esa.int/web/gaia/data-release-2
*
* \li <em>Gaia Data Release 2. Summary of the contents and survey
* properties.</em> Gaia Collaboration, Brown, A.G.A., et al.:
* https://arxiv.org/abs/1804.09365v2
*
* \li Gaia Data Release 2. Documentation release 1.2:
* https://gea.esac.esa.int/archive/documentation/GDR2/index.html
*
* \li Gaia Early Data Release 3 - online resources:
* https://www.cosmos.esa.int/web/gaia/early-data-release-3
*
* \li <em>Gaia Early Data Release 3. Summary of the contents and survey
* properties.</em> Gaia Collaboration, A.G.A. Brown, A. Vallenari, T. Prusti,
* J.H.J. de Bruijne, et al.:
* https://www.aanda.org/articles/aa/pdf/forth/aa39657-20.pdf
*
* \li Gaia Early Data Release 3. Documentation release 1.0:
* https://gea.esac.esa.int/archive/documentation/GEDR3/index.html
*
* \b Credits
*
* This work has made use of data from the European Space Agency (ESA) mission
* Gaia (https://www.cosmos.esa.int/gaia), processed by the Gaia Data
* Processing and Analysis Consortium (DPAC,
* https://www.cosmos.esa.int/web/gaia/dpac/consortium). Funding for the DPAC
* has been provided by national institutions, in particular the institutions
* participating in the Gaia Multilateral Agreement.
*
* \sa StarDatabaseFile, APASSDatabaseFile
* \ingroup point_source_databases
*/
class PCL_CLASS GaiaDatabaseFile : public StarDatabaseFile
{
public:
/*!
* Default constructor.
*
* Constructs an invalid instance that cannot be used until initialized by
* calling the Open() member function.
*/
GaiaDatabaseFile() = default;
/*!
* Constructs a &GaiaDatabaseFile instance initialized from the specified
* point source database file in XPSD format. As of writing this
* documentation (December 2020), The Gaia DR2 and EDR3 catalogs are
* available.
*
* In the event of errors or invalid data, this constructor will throw the
* appropriate Error exception.
*/
GaiaDatabaseFile( const String& filePath )
: StarDatabaseFile( filePath )
{
static_assert( sizeof( EncodedStarData ) == 32, "Invalid sizeof( GaiaDatabaseFile::EncodedStarData )" );
if ( Metadata().databaseIdentifier == "GaiaEDR3" )
m_dr = "EDR3";
else if ( Metadata().databaseIdentifier == "GaiaDR2" )
{
m_dr = "DR2";
StringList tokens;
Metadata().databaseVersion.Break( tokens, '.' );
// Make sure we reject an unsupported DR2 version older than 1.0.2
if ( tokens.Length() < 3 || tokens[0].ToInt() < 1 || tokens[1].ToInt() < 0 || tokens[2].ToInt() < 2 )
throw Error( "Unsupported Gaia DR2 database version '"
+ Metadata().databaseVersion + "': " + filePath );
}
else
throw Error( "Invalid or unsupported Gaia database file with unknown identifier '"
+ Metadata().databaseIdentifier + "': " + filePath );
}
/*!
* Move assignment operator. Returns a reference to this object.
*/
GaiaDatabaseFile& operator =( GaiaDatabaseFile&& ) = default;
/*!
* Deleted copy constructor. %GaiaDatabaseFile instances are unique,
* hence cannot be copied.
*/
GaiaDatabaseFile( const GaiaDatabaseFile& ) = delete;
/*!
* Deleted copy assignment operator. %GaiaDatabaseFile instances are
* unique, hence cannot be copied.
*/
GaiaDatabaseFile& operator =( const GaiaDatabaseFile& ) = delete;
/*!
* Performs a search operation for point sources matching the specified
* criteria.
*
* This member function performs a fast indexed search for point sources in
* this database file matching the criteria defined in the specified \a data
* structure. See the GaiaSearchData structure for detailed information on
* search parameters and output data.
*
* Summarily, search criteria include:
*
* \li The region of the sky where point sources will be searched for. This
* region is defined by the equatorial coordinates of a field center and a
* field radius.
*
* \li An optional range of magnitudes.
*
* \li Optional inclusion/exclusion flags.
*
* \li An optional limit for the number of sources included in the search
* result.
*
* The result of the search operation is also returned in the specified
* \a data structure, including, among others, the following items:
*
* \li The list of point sources found.
*
* \li Instrumentation items for performance analysis, including: total
* search time, time used for I/O operations, total I/O operations, time
* used for data decoding, and time used for data decompression.
*/
void Search( GaiaSearchData& data ) const
{
ElapsedTime T;
for ( const XPSD::IndexTree& tree : m_index )
tree.Search( data.centerRA, data.centerDec, data.radius, &data );
data.timeTotal += T();
}
/*!
* Returns the name of the Gaia data release corresponding to the data
* available in this database file. As of writing this documentation
* (December 2020), this member function can return either "DR2" or "EDR3".
*/
const IsoString& DataRelease() const
{
return m_dr;
}
private:
IsoString m_dr; // data release, one of "DR2", "EDR3"
#pragma pack(push, 1)
/*
* Encoded star record (32 bytes uncompressed).
*/
struct EncodedStarData
{
// Projected coordinates relative to the origin of the parent quadtree
// node, in 0.002 mas units.
uint32 dx;
uint32 dy;
// Parallax in mas units.
float parx;
// Proper motions, mas/yr.
float pmra;
float pmdec;
// Mean magnitudes in 0.001 mag units, encoded as (mag + 1.5)*1000.
uint16 magG;
uint16 magBP;
uint16 magRP;
// Right ascension correction for high declinations, in 0.01 mas units.
int16 dra;
// Data availability and quality flags.
uint32 flags;
};
#pragma pack(pop)
void LoadData( void* block, uint64 offset, uint32 size, void* searchData ) const override
{
ElapsedTime T;
StarDatabaseFile::LoadData( block, offset, size, searchData );
reinterpret_cast<GaiaSearchData*>( searchData )->timeIO += T();
++reinterpret_cast<GaiaSearchData*>( searchData )->countIO;
}
void Uncompress( ByteArray& block, uint32 uncompressedSize, void* searchData ) const override
{
ElapsedTime T;
StarDatabaseFile::Uncompress( block, uncompressedSize, searchData );
reinterpret_cast<GaiaSearchData*>( searchData )->timeUncompress += T();
}
void GetEncodedData( const ByteArray& data, const XPSD::IndexTree& tree, const XPSD::IndexNode& node, void* searchData ) const override
{
ElapsedTime T;
GaiaSearchData* search = reinterpret_cast<GaiaSearchData*>( searchData );
double r = Rad( search->radius );
const EncodedStarData* S = reinterpret_cast<const EncodedStarData*>( data.Begin() );
int count = int( data.Size() / sizeof( EncodedStarData ) );
int matched = 0;
for ( int i = 0; i < count; ++i, ++S )
if ( search->requiredFlags == 0 || (S->flags & search->requiredFlags) == search->requiredFlags )
if ( search->inclusionFlags == 0 || (S->flags & search->inclusionFlags) != 0 )
if ( search->exclusionFlags == 0 || (S->flags & search->exclusionFlags) == 0 )
{
float magG = 0.001*S->magG - 1.5;
if ( magG >= search->magnitudeLow )
if ( magG <= search->magnitudeHigh )
{
GaiaStarData star;
double x = node.x0 + double( S->dx )/3600/1000/500;
double y = node.y0 + double( S->dy )/3600/1000/500;
tree.Unproject( star.ra, star.dec, x, y );
if ( unlikely( S->dra != 0 ) )
{
star.ra += double( S->dra )/3600/1000/100;
if ( star.ra < 0 )
star.ra += 360;
else if ( star.ra >= 360 )
star.ra -= 360;
}
if ( Distance( search->centerRA, search->centerDec, star.ra, star.dec ) < r )
{
if ( search->stars.Length() < size_type( search->sourceLimit ) )
{
star.parx = S->parx;
star.pmra = S->pmra;
star.pmdec = S->pmdec;
star.magG = magG;
star.magBP = 0.001*S->magBP - 1.5;
star.magRP = 0.001*S->magRP - 1.5;
star.flags = S->flags;
search->stars << star;
}
else
++search->excessCount;
++matched;
}
}
}
search->rejectCount += count - matched;
search->timeDecode += T();
}
friend class GaiaDR2DatabaseFileGenerator;
friend class GaiaEDR3DatabaseFileGenerator;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_GaiaDatabaseFile_h
// ----------------------------------------------------------------------------
// EOF pcl/GaiaDatabaseFile.h - Released 2022-03-12T18:59:29Z
-498
View File
@@ -1,498 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/GaussianFilter.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_GaussianFilter_h
#define __PCL_GaussianFilter_h
/// \file pcl/GaussianFilter.h
#include <pcl/Defs.h>
#include <pcl/KernelFilter.h>
#include <pcl/Math.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class GaussianFilter
* \brief A kernel filter implementing a discrete Gaussian distribution in two
* dimensions.
*
* A %GaussianFilter object is a specialized KernelFilter whose elements are
* calculated as a discrete representation of an elliptical Gaussian function
* centered at the origin:
*
* G(x,y) = Exp( -( x^2/(2*sx^2) + y^2/(2*sy^2) ) )
*
* where sx and sy are the standard deviations of the Gaussian distribution on
* the horizontal and vertical axes, respectively.
*
* %GaussianFilter also supports arbitrary rotation around the origin. When the
* filter is rotated, the coordinates x, y in the equation above are replaced
* by their rotated counterparts.
*
* A %GaussianFilter instance is formally defined by the following parameters:
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>\e sigma</td> <td>Standard deviation of the filter distribution on the X axis (sigma > 0).</td></tr>
* <tr><td>\e rho</td> <td>The ratio sy/sx (see equation above) of the generated filter distribution (0 <= rho <= 1).</td></tr>
* <tr><td>\e theta</td> <td>Rotation angle of the horizontal axis in radians (0 <= theta < PI). This parameter only makes sense when rho < 1.</td></tr>
* <tr><td>\e epsilon</td> <td>Maximum truncation error of the computed filter coefficients (eps > 0).</td></tr>
* </table>
*
* \sa KernelFilter, VariableShapeFilter, MoffatFilter, LinearFilter,
* MeanFilter
*/
class PCL_CLASS GaussianFilter : public KernelFilter
{
public:
/*!
* Constructs an empty %GaussianFilter object with default functional
* parameters: sigma=2, epsilon=0.01, rho=1, theta=0.
*/
GaussianFilter() = default;
/*!
* Constructs a %GaussianFilter object given the standard deviation
* \a sigma > 0 and truncation error \a epsilon > 0. Assigns an optional
* \a name to the new filter object.
*/
GaussianFilter( float sigma, float epsilon = 0.01, const String& name = String() )
{
Initialize( sigma, epsilon, 1, 0 );
Rename( name );
}
/*!
* Constructs a %GaussianFilter object given the standard deviation
* \a sigma > 0, truncation error \a epsilon > 0, aspect ratio
* 0 <= \a rho <= 1, and rotation angle 0 <= \a theta <= PI in radians.
* Assigns an optional \a name to the new filter object.
*/
GaussianFilter( float sigma, float epsilon, float rho, float theta = 0, const String& name = String() )
{
Initialize( sigma, epsilon, rho, theta );
Rename( name );
}
/*!
* Constructs a %GaussianFilter object given the odd kernel size \a n >= 3
* and truncation error \a epsilon > 0. Assigns an optional \a name to the
* new filter object.
*/
GaussianFilter( int n, float epsilon = 0.01, const String& name = String() )
{
Initialize( n, epsilon, 1, 0 );
Rename( name );
}
/*!
* Constructs a %GaussianFilter object given the odd kernel size \a n >= 3,
* truncation error \a epsilon > 0, aspect ratio 0 <= \a rho <= 1, and
* rotation angle 0 <= \a theta <= PI in radians. Assigns an optional
* \a name to the new filter object.
*/
GaussianFilter( int n, float epsilon, float rho, float theta = 0, const String& name = String() )
{
Initialize( n, epsilon, rho, theta );
Rename( name );
}
/*!
* Copy constructor.
*/
GaussianFilter( const GaussianFilter& ) = default;
/*!
* Move constructor.
*/
GaussianFilter( GaussianFilter&& ) = default;
/*!
*/
KernelFilter* Clone() const override
{
return new GaussianFilter( *this );
}
/*!
* Returns a separable filter equivalent to this Gaussian kernel filter.
*
* A Gaussian filter is the only circularly symmetric, two-dimensional
* separable filter. This reimplementation returns a separable filter only
* if this object represents an undistorted/unrotated Gaussian function,
* that is, when its aspect ratio is 1. Otherwise an empty SeparableFilter
* object is returned since the filter matrix is not separable.
*/
SeparableFilter AsSeparableFilter( float tolerance = __PCL_DEFAULT_FILTER_SEPARABILITY_TOLERANCE ) const override
{
if ( m_rho == 1 )
{
FVector v = coefficients.RowVector( Size()>>1 );
return SeparableFilter( v, v );
}
return SeparableFilter();
}
/*!
* Returns true iff this filter is separable,
*
* A Gaussian filter is separable. As reimplemented in %GaussianFilter, this
* member function returns true for undistorted/unrotated Gaussian filters,
* that is, when this object's aspect ratio is 1.
*/
bool IsSeparable() const override
{
return m_rho == 1;
}
/*!
* Copy assignment operator. Returns a reference to this object.
*/
GaussianFilter& operator =( const GaussianFilter& x )
{
(void)KernelFilter::operator =( x );
m_sigma = x.m_sigma;
m_epsilon = x.m_epsilon;
m_rho = x.m_rho;
m_theta = x.m_theta;
return *this;
}
/*!
* Move assignment operator. Returns a reference to this object.
*/
GaussianFilter& operator =( GaussianFilter&& x )
{
(void)KernelFilter::operator =( std::move( x ) );
m_sigma = x.m_sigma;
m_epsilon = x.m_epsilon;
m_rho = x.m_rho;
m_theta = x.m_theta;
return *this;
}
/*!
* Returns the standard deviation of the filter distribution on the X
* (horizontal) axis.
*/
float SigmaX() const
{
return m_sigma;
}
/*!
* Returns the standard deviation of the filter distribution on the Y
* (vertical) axis.
*/
float SigmaY() const
{
return m_rho*m_sigma;
}
/*!
* Returns the standard deviation of the filter distribution on the X
* (horizontal) axis.
*
* This function is an alias to SigmaX().
*/
float Sigma() const
{
return SigmaX();
}
/*!
* Returns the maximum truncation error of the filter coefficients.
*/
float Truncation() const
{
return m_epsilon;
}
/*!
* Returns the aspect ratio of the filter distribution. This is the ratio
* vertical:horizontal between filter axes in the range [0,1].
*/
float AspectRatio() const
{
return m_rho;
}
/*!
* Returns the rotation angle of the filter distribution. This is the
* rotation angle in radians with respect to the central pixel, in the
* range [0,+PI].
*/
float RotationAngle() const
{
return m_theta;
}
/*!
* Returns the full width at half maximum (FWHM), in sigma units, for the
* horizontal axis of the elliptical Gaussian filter distribution.
*/
double FWHMx() const
{
return 2.3548200450309493 * m_sigma;
}
/*!
* Returns the full width at half maximum (FWHM), in sigma units, for the
* vertical axis of the elliptical Gaussian filter distribution.
*/
double FWHMy() const
{
return m_rho * FWHMx();
}
/*!
* Returns the full width at half maximum, in sigma units, for the
* horizontal axis of the elliptical Gaussian filter distribution.
*
* This function is an alias to FWHMx().
*/
double FWHM() const
{
return FWHMx();
}
/*!
* Recalculates filter coefficients for the specified sigma \a sigma > 0,
* truncation error \a epsilon > 0, aspect ratio 0 <= \a rho <= 1, and
* rotation angle 0 <= \a theta <= PI in radians.
*/
void Set( float sigma, float epsilon, float rho, float theta )
{
Initialize( sigma, epsilon, rho, theta );
}
/*!
* Recalculates filter coefficients for the specified sigma \a sigma > 0,
* truncation error \a epsilon > 0, and aspect ratio 0 <= \a rho <= 1. Does
* not change the current rotation angle.
*/
void Set( float sigma, float epsilon, float rho )
{
Initialize( sigma, epsilon, rho, m_theta );
}
/*!
* Recalculates filter coefficients for the specified sigma \a sigma > 0 and
* truncation error \a epsilon > 0. Does not change the current aspect ratio
* and rotation angle.
*/
void Set( float sigma, float epsilon )
{
Initialize( sigma, epsilon, m_rho, m_theta );
}
/*!
* Recalculates filter coefficients for the specified sigma \a sigma > 0.
* The current coefficient truncation error, aspect ratio and rotation angle
* are not changed.
*/
void Set( float sigma )
{
Initialize( sigma, m_epsilon, m_rho, m_theta );
}
/*!
* This is a convenience member function, equivalent to Set( sigma ).
*/
void SetSigma( float sigma )
{
Set( sigma );
}
/*!
* This is a convenience member function, equivalent to
* Set( Sigma(), epsilon ).
*/
void SetTruncation( float epsilon )
{
Set( m_sigma, epsilon );
}
/*!
* This is a convenience member function, equivalent to
* Set( Sigma(), Truncation(), rho ).
*/
void SetAspectRatio( float rho )
{
Set( m_sigma, m_epsilon, rho );
}
/*!
* This is a convenience member function, equivalent to
* Set( Sigma(), Truncation(), AspectRatio(), theta ).
*/
void SetRotationAngle( float theta )
{
Set( m_sigma, m_epsilon, m_rho, theta );
}
/*!
* Recalculates filter coefficients for the given odd kernel size \a n >= 3.
* This routine computes the required standard deviation to sample the
* Gaussian function on a matrix of the specified size, preserving the
* current coefficient truncation, aspect ratio and rotation angle.
*/
void Resize( int n ) override
{
Initialize( n, m_epsilon, m_rho, m_theta );
}
/*!
* Exchanges two Gaussian filters \a x1 and \a x2.
*/
friend void Swap( GaussianFilter& x1, GaussianFilter& x2 )
{
pcl::Swap( static_cast<KernelFilter&>( x1 ), static_cast<KernelFilter&>( x2 ) );
pcl::Swap( x1.m_sigma, x2.m_sigma );
pcl::Swap( x1.m_rho, x2.m_rho );
pcl::Swap( x1.m_theta, x2.m_theta );
pcl::Swap( x1.m_epsilon, x2.m_epsilon );
}
private:
float m_sigma = 2; // standard deviation, horizontal axis
float m_rho = 1; // vertical:horizontal axes ratio
float m_theta = 0; // rotation angle in radians, [0,+pi]
float m_epsilon = 0.01F; // maximum truncation error in sigma units
void Initialize( float s, float e, float r, float a )
{
PCL_PRECONDITION( s > 0 )
PCL_PRECONDITION( e > 0 )
PCL_PRECONDITION( r >= 0 && r <= 1 )
PCL_PRECONDITION( a >= 0 && a <= Const<float>::pi() )
m_sigma = Abs( s );
m_epsilon = Abs( e );
m_rho = Range( r, 0.0F, 1.0F );
m_theta = Range( a, 0.0F, Const<float>::pi() );
KernelFilter::Resize( 1 + (Max( 1, RoundInt( m_sigma * Sqrt( -2*Ln( m_epsilon ) ) ) ) << 1) );
Rebuild();
}
void Initialize( int n, float e, float r, float a )
{
PCL_PRECONDITION( n == 0 || n >= 3 && (n & 1) != 0 )
PCL_PRECONDITION( e > 0 )
PCL_PRECONDITION( r >= 0 && r <= 1 )
PCL_PRECONDITION( a >= 0 && a <= Const<float>::pi() )
KernelFilter::Resize( n );
m_epsilon = Abs( e );
m_sigma = (Size() >> 1)/Sqrt( -2*Ln( m_epsilon ) );
m_rho = Range( r, 0.0F, 1.0F );
m_theta = Range( a, 0.0F, Const<float>::pi() );
Rebuild();
}
void Rebuild()
{
int size = Size();
if ( size == 0 )
return;
float* __restrict__ h = *coefficients;
double sx = m_sigma;
double sy = m_rho * sx;
if ( m_theta == 0 || m_rho == 1 )
{
double twosx2 = 2*sx*sx;
double twosy2 = 2*sy*sy;
for ( int n2 = size >> 1, dy = -n2; dy <= n2; ++dy )
if ( dy > 0 )
for ( int dx = 0; dx < size; ++dx, ++h )
*h = *(h - ((dy+dy)*size));
else
for ( int dx = -n2; dx <= n2; ++dx, ++h )
*h = (dx > 0) ? *(h - (dx+dx)) : float( Exp( -(dx*dx/twosx2 + dy*dy/twosy2) ) );
}
else
{
double st, ct; SinCos( double( m_theta ), st, ct );
double sct = st*ct;
double st2 = st*st;
double ct2 = ct*ct;
double twosx2 = 2*sx*sx;
double twosy2 = 2*sy*sy;
double p1 = ct2/twosx2 + st2/twosy2;
double p2 = sct/twosy2 - sct/twosx2;
double p3 = st2/twosx2 + ct2/twosy2;
for ( int n2 = size >> 1, dy = -n2; dy <= n2; ++dy )
{
double twop2dy = 2*p2*dy;
double p3dy2 = p3*dy*dy;
for ( int dx = -n2; dx <= n2; ++dx, ++h )
*h = float( Exp( -(p1*dx*dx + twop2dy*dx + p3dy2) ) );
}
}
}
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_GaussianFilter_h
// ----------------------------------------------------------------------------
// EOF pcl/GaussianFilter.h - Released 2022-03-12T18:59:29Z
-277
View File
@@ -1,277 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/GeometricTransformation.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_GeometricTransformation_h
#define __PCL_GeometricTransformation_h
/// \file pcl/GeometricTransformation.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/ImageTransformation.h>
#include <pcl/PixelInterpolation.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class GeometricTransformation
* \brief Abstract base class of all PCL geometric image transformations.
*
* %GeometricTransformation represents a geometrical transformation that can be
* applied to any image type defined in PCL.
*
* \sa InterpolatingGeometricTransformation, ImageTransformation
*/
class PCL_CLASS GeometricTransformation : public virtual ImageTransformation
{
public:
/*!
* Constructs a %GeometricTransformation object.
*/
GeometricTransformation() = default;
/*!
* Copy constructor.
*/
GeometricTransformation( const GeometricTransformation& ) = default;
/*!
* Destroys a %GeometricTransformation object.
*/
virtual ~GeometricTransformation()
{
}
/*!
* Predicts transformed image dimensions.
*
* \param[in,out] width Reference to a variable whose value is a horizontal
* dimension in pixels (width). On output, it will receive the
* predicted horizontal dimension after the transformation.
*
* \param[in,out] height Reference to a variable whose value is a vertical
* dimension in pixels (height). On output, it will receive the
* predicted vertical dimension after the transformation.
*
* \note This is a pure virtual member function that must be reimplemented
* in every derived class.
*/
virtual void GetNewSizes( int& width, int& height ) const = 0;
};
// ----------------------------------------------------------------------------
/*!
* \class InterpolatingGeometricTransformation
* \brief Abstract base class of all PCL interpolating geometric image
* transformations.
*
* %InterpolatingGeometricTransformation represents a geometrical
* transformation that uses a pixel interpolating algorithm to yield
* transformed pixel sample values. Transformations implemented as derived
* classes of %InterpolatingGeometricTransformation can be applied to all
* standard image types defined in PCL.
*
* \sa GeometricTransformation, PixelInterpolation, ImageTransformation
*/
class PCL_CLASS InterpolatingGeometricTransformation : public GeometricTransformation
{
public:
/*!
* Constructs a %InterpolatingGeometricTransformation object that will use
* the specified pixel interpolation \a p.
*
* The specified PixelInterpolation object must remain valid and accessible
* as long as this object exists, or until this object is associated with a
* different pixel interpolation.
*/
InterpolatingGeometricTransformation( PixelInterpolation& p )
: m_interpolation( &p )
{
PCL_CHECK( m_interpolation != nullptr )
}
/*!
* Copy constructor. The constructed object will use the same pixel
* interpolation as the specified source object.
*
* The PixelInterpolation object used by both this object and the source
* object must remain valid and accessible as long as at least one of both
* objects is associated with it.
*/
InterpolatingGeometricTransformation( const InterpolatingGeometricTransformation& ) = default;
/*!
* Move constructor.
*/
InterpolatingGeometricTransformation( InterpolatingGeometricTransformation&& x )
: GeometricTransformation( x )
, m_interpolation( x.m_interpolation )
, m_unclipped( x.m_unclipped )
{
x.m_interpolation = nullptr;
}
/*!
* Copy assignment operator. Returns a reference to this object.
*
* After assignment, this object will use the same pixel interpolation as
* the specified source object. The previously used pixel interpolation is
* simply forgotten by this object, which will no longer depend on it.
*
* The PixelInterpolation object used by both this object and the source
* object must remain valid and accessible as long as at least one of both
* objects is associated with it.
*/
InterpolatingGeometricTransformation& operator =( const InterpolatingGeometricTransformation& ) = default;
/*!
* Move assignment operator. Returns a reference to this object.
*/
InterpolatingGeometricTransformation& operator =( InterpolatingGeometricTransformation&& x )
{
m_interpolation = x.m_interpolation;
x.m_interpolation = nullptr;
m_unclipped = x.m_unclipped;
return *this;
}
/*!
* Returns a reference to the unmodifiable PixelInterpolation object that
* this transformation is currently using.
*/
const PixelInterpolation& Interpolation() const
{
PCL_CHECK( m_interpolation != nullptr )
return *m_interpolation;
}
/*!
* Returns a reference to the PixelInterpolation object that this
* transformation is currently using.
*/
PixelInterpolation& Interpolation()
{
PCL_CHECK( m_interpolation != nullptr )
return *m_interpolation;
}
/*!
* Causes this transformation to use the specified pixel interpolation \a p.
*
* The new pixel interpolation will be used to generate transformed pixel
* values after calling this function. The previously used pixel
* interpolation is simply forgotten by this object, which will no longer
* depend on it.
*
* The specified PixelInterpolation object must remain valid and accessible
* as long as this object exists, or until this object is associated with a
* different pixel interpolation.
*/
void SetInterpolation( PixelInterpolation& p )
{
m_interpolation = &p;
PCL_CHECK( m_interpolation != nullptr )
}
/*!
* Returns true if this image transformation applies unclipped pixel
* interpolations. Unclipped interpolations don't constrain interpolated
* pixel sample values to the native range of the pixel data type of the
* transformed image. This allows to apply interpolating transformations to
* images that exceed their representable ranges; for example, when images
* are used to store and manipulate arbitrary matrices for convenience.
*
* Unclipped transformations are always disabled by default.
*/
bool UsingUnclippedInterpolation() const
{
return m_unclipped;
}
/*!
* Enables the use of unclipped pixel interpolations. See
* UsingUnclippedInterpolation() for more information.
*/
void EnableUnclippedInterpolation( bool enable = true )
{
m_unclipped = enable;
}
/*!
* Disables the use of unclipped pixel interpolations. See
* UsingUnclippedInterpolation() for more information.
*/
void DisableUnclippedInterpolation( bool disable = true )
{
EnableUnclippedInterpolation( !disable );
}
protected:
PixelInterpolation* m_interpolation = nullptr;
bool m_unclipped = false;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_GeometricTransformation_h
// ----------------------------------------------------------------------------
// EOF pcl/GeometricTransformation.h - Released 2022-03-12T18:59:29Z
-522
View File
@@ -1,522 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/GlobalSettings.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_GlobalSettings_h
#define __PCL_GlobalSettings_h
/// \file pcl/GlobalSettings.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/Color.h>
#include <pcl/String.h>
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Font.h>
#endif
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::GlobalVariableType
* \brief Data types for global platform variables
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>GlobalVariableType::Undefined</td> <td>Indicates that the requested global variable does not exist.</td></tr>
* <tr><td>GlobalVariableType::Flag</td> <td>Boolean value.</td></tr>
* <tr><td>GlobalVariableType::Integer</td> <td>Signed integer.</td></tr>
* <tr><td>GlobalVariableType::Unsigned</td> <td>Unsigned integer.</td></tr>
* <tr><td>GlobalVariableType::Real</td> <td>Floating point real (IEEE 64-bit floating point).</td></tr>
* <tr><td>GlobalVariableType::Color</td> <td>RGBA color (uint32).</td></tr>
* <tr><td>GlobalVariableType::Font</td> <td>A font face (a string).</td></tr>
* <tr><td>GlobalVariableType::String</td> <td>A UTF-16 string.</td></tr>
* </table>
*/
namespace GlobalVariableType
{
enum value_type
{
Undefined, // The requested global variable doesn't exist
Flag, // bool
Integer, // int
Unsigned, // unsigned
Real, // double
Color, // RGBA (= uint32)
Font, // Font
String // String
};
}
// ----------------------------------------------------------------------------
/*!
* \class PixInsightSettings
* \brief Retrieves global settings from the PixInsight core application
*
* PixInsight global settings, also known as <em>global variables</em>, are
* identifier/value pairs available from the core application to all installed
* modules. Settings can be of six types: flags (or Boolean), integer (signed
* and unsigned), real (floating point), color, font, and string. See the
* pcl::GlobalVariableType namespace for more details.
*
* Below is a complete list of all global settings available in current
* versions of the PixInsight platform (updated as of core version 1.8.8-13).
*
* <h3>PixInsight Public Global Variables</h3>
*
* <h4>Global %Flags</h4>
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>Application/AutoUIScaling</td><td></td></tr>
* <tr><td>Application/HealRegistryInformationOnUpdates</td><td></td></tr>
* <tr><td>ColorManagement/DefaultEmbedProfilesInGrayscaleImages</td><td></td></tr>
* <tr><td>ColorManagement/DefaultEmbedProfilesInRGBImages</td><td></td></tr>
* <tr><td>ColorManagement/DefaultGamutCheckEnabled</td><td></td></tr>
* <tr><td>ColorManagement/DefaultProofingEnabled</td><td></td></tr>
* <tr><td>ColorManagement/IsEnabled</td><td></td></tr>
* <tr><td>ColorManagement/IsValid</td><td>Read-only.</td></tr>
* <tr><td>ColorManagement/UseLowResolutionCLUTs</td><td></td></tr>
* <tr><td>ColorManagement/UseProofingBPC</td><td></td></tr>
* <tr><td>ImageWindow/BackupFiles</td><td></td></tr>
* <tr><td>ImageWindow/CreatePreviewsFromCoreProperties</td><td></td></tr>
* <tr><td>ImageWindow/Default24BitScreenLUT</td><td></td></tr>
* <tr><td>ImageWindow/DefaultEmbedProperties</td><td></td></tr>
* <tr><td>ImageWindow/DefaultEmbedThumbnails</td><td></td></tr>
* <tr><td>ImageWindow/DefaultMasksShown</td><td></td></tr>
* <tr><td>ImageWindow/DefaultMetricResolution</td><td></td></tr>
* <tr><td>ImageWindow/FastScreenRenditions</td><td></td></tr>
* <tr><td>ImageWindow/FileFormatWarnings</td><td></td></tr>
* <tr><td>ImageWindow/FollowDownloadLocations</td><td></td></tr>
* <tr><td>ImageWindow/HighDPIRenditions</td><td></td></tr>
* <tr><td>ImageWindow/LoadAstrometricSolutions</td><td></td></tr>
* <tr><td>ImageWindow/LoadInitialProcessingFromCoreProperties</td><td></td></tr>
* <tr><td>ImageWindow/MeasureScreenRenderingPerformance</td><td></td></tr>
* <tr><td>ImageWindow/NativeFileDialogs</td><td></td></tr>
* <tr><td>ImageWindow/ProjectVerifyIncrementalChecksums</td><td></td></tr>
* <tr><td>ImageWindow/RememberFileOpenType</td><td></td></tr>
* <tr><td>ImageWindow/RememberFileSaveType</td><td></td></tr>
* <tr><td>ImageWindow/ShowActiveSTFIndicators</td><td></td></tr>
* <tr><td>ImageWindow/ShowCaptionCurrentChannels</td><td></td></tr>
* <tr><td>ImageWindow/ShowCaptionFullPaths</td><td></td></tr>
* <tr><td>ImageWindow/ShowCaptionIdentifiers</td><td></td></tr>
* <tr><td>ImageWindow/ShowCaptionZoomRatios</td><td></td></tr>
* <tr><td>ImageWindow/ShowViewSelectorImageThumbnails</td><td></td></tr>
* <tr><td>ImageWindow/StrictFileSaveMode</td><td></td></tr>
* <tr><td>ImageWindow/SwapCompression</td><td></td></tr>
* <tr><td>ImageWindow/TouchEvents</td><td></td></tr>
* <tr><td>ImageWindow/UseFileNamesAsImageIdentifiers</td><td></td></tr>
* <tr><td>ImageWindow/VerboseNetworkOperations</td><td>Not available on Windows.</td></tr>
* <tr><td>ImageWindow/ZoomAtCursor</td><td></td></tr>
* <tr><td>MainWindow/AcceptDroppedFiles</td><td></td></tr>
* <tr><td>MainWindow/AnimateCombo</td><td></td></tr>
* <tr><td>MainWindow/AnimateMenu</td><td></td></tr>
* <tr><td>MainWindow/AnimateToolBox</td><td></td></tr>
* <tr><td>MainWindow/AnimateToolTip</td><td></td></tr>
* <tr><td>MainWindow/AnimateWindows</td><td></td></tr>
* <tr><td>MainWindow/CapitalizedMenuBars</td><td></td></tr>
* <tr><td>MainWindow/CheckForUpdatesAtStartup</td><td></td></tr>
* <tr><td>MainWindow/ConfirmProgramTermination</td><td></td></tr>
* <tr><td>MainWindow/DesktopSettingsAware</td><td></td></tr>
* <tr><td>MainWindow/DoubleClickLaunchesOpenDialog</td><td></td></tr>
* <tr><td>MainWindow/ExpandFavoritesAtStartup</td><td></td></tr>
* <tr><td>MainWindow/ExpandMostUsedAtStartup</td><td></td></tr>
* <tr><td>MainWindow/ExpandRecentlyUsedAtStartup</td><td></td></tr>
* <tr><td>MainWindow/ExplodeIcons</td><td></td></tr>
* <tr><td>MainWindow/FadeAutoHideWindows</td><td></td></tr>
* <tr><td>MainWindow/FadeMenu</td><td></td></tr>
* <tr><td>MainWindow/FadeToolTip</td><td></td></tr>
* <tr><td>MainWindow/FadeWindows</td><td></td></tr>
* <tr><td>MainWindow/FadeWorkspaces</td><td></td></tr>
* <tr><td>MainWindow/FullScreenAtStartup</td><td></td></tr>
* <tr><td>MainWindow/HighQualityWallpapers</td><td></td></tr>
* <tr><td>MainWindow/HoverableAutoHideWindows</td><td></td></tr>
* <tr><td>MainWindow/ImplodeIcons</td><td></td></tr>
* <tr><td>MainWindow/MaximizeAtStartup</td><td></td></tr>
* <tr><td>MainWindow/NativeMenuBar</td><td></td></tr>
* <tr><td>MainWindow/OpenURLsWithInternalBrowser</td><td></td></tr>
* <tr><td>MainWindow/OpenResourcesOnNewWebBrowserWindows</td><td></td></tr>
* <tr><td>MainWindow/PrivateWebBrowsingMode</td><td></td></tr>
* <tr><td>MainWindow/ShowFavorites</td><td></td></tr>
* <tr><td>MainWindow/ShowMostUsed</td><td></td></tr>
* <tr><td>MainWindow/ShowRecentlyUsed</td><td></td></tr>
* <tr><td>MainWindow/ShowSplashAtStartup</td><td></td></tr>
* <tr><td>MainWindow/ShowViewListImageThumbnails</td><td></td></tr>
* <tr><td>MainWindow/ShowWorkspaceThumbnails</td><td></td></tr>
* <tr><td>MainWindow/TranslucentAutoHideWindows</td><td></td></tr>
* <tr><td>MainWindow/TranslucentChildWindows</td><td></td></tr>
* <tr><td>MainWindow/TranslucentWindows</td><td></td></tr>
* <tr><td>MainWindow/UseWallpapers</td><td></td></tr>
* <tr><td>MainWindow/WindowButtonsOnTheLeft</td><td></td></tr>
* <tr><td>Process/AlertOnProcessCompleted</td><td></td></tr>
* <tr><td>Process/BackupFiles</td><td></td></tr>
* <tr><td>Process/EnableCUDAAcceleration</td><td></td></tr>
* <tr><td>Process/EnableExecutionStatistics</td><td></td></tr>
* <tr><td>Process/EnableLaunchStatistics</td><td></td></tr>
* <tr><td>Process/EnableParallelCoreColorManagement</td><td></td></tr>
* <tr><td>Process/EnableParallelCoreRendering</td><td></td></tr>
* <tr><td>Process/EnableParallelModuleProcessing</td><td></td></tr>
* <tr><td>Process/EnableParallelProcessing</td><td></td></tr>
* <tr><td>Process/EnableThreadCPUAffinity</td><td></td></tr>
* <tr><td>Process/GenerateScriptComments</td><td></td></tr>
* <tr><td>Process/InitCUDARuntimeAtStartup</td><td></td></tr>
* <tr><td>Process/VerifyScriptChecksums</td><td></td></tr>
* </table>
*
* <h4>Global Integers</h4>
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>Application/FontResolution</td><td>In dots per inch.</td></tr>
* <tr><td>ColorManagement/DefaultRenderingIntent</td><td>See the pcl::ICCRenderingIntent namespace.</td></tr>
* <tr><td>ColorManagement/OnMissingProfile</td><td>Core application policies. See the documentation for ColorManagementSetup.</td></tr>
* <tr><td>ColorManagement/OnProfileMismatch</td><td>Core application policies. See the documentation for ColorManagementSetup.</td></tr>
* <tr><td>ColorManagement/ProofingIntent</td><td>See the pcl::ICCRenderingIntent namespace.</td></tr>
* <tr><td>ImageWindow/CursorTolerance</td><td>In device pixels.</td></tr>
* <tr><td>ImageWindow/DefaultMaskMode</td><td>See the pcl::MaskMode namespace.</td></tr>
* <tr><td>ImageWindow/DefaultTransparencyMode</td><td>See the pcl::TransparencyMode namespace.</td></tr>
* <tr><td>ImageWindow/FastScreenRenditionThreshold</td><td>In MiB.</td></tr>
* <tr><td>ImageWindow/ImageThumbnailSize</td><td>In image pixels.</td></tr>
* <tr><td>ImageWindow/ProjectThumbnailSize</td><td>In image pixels.</td></tr>
* <tr><td>ImageWindow/WheelStepAngle</td><td>In degrees, unsigned.</td></tr>
* <tr><td>ImageWindow/WheelDirection</td><td>When >= 0, rotating forward zooms out. When < 0, rotating forward zooms in.</td></tr>
* <tr><td>MainWindow/MaxRecentFiles</td><td>Maximum length of recent file menu lists.</td></tr>
* <tr><td>Process/AutoSavePSMPeriod</td><td>In seconds.</td></tr>
* <tr><td>Process/ConsoleDelay</td><td>In milliseconds.</td></tr>
* <tr><td>Process/MaxConsoleLines</td><td>Maximum number of stored text lines on %Process %Console.</td></tr>
* <tr><td>Process/MaxModuleThreadPriority</td><td>From 0=idle to 7=real-time.</td></tr>
* <tr><td>Process/MaxProcessors</td><td>Maximum number of processor cores allowed for installed modules.</td></tr>
* <tr><td>Process/MaxFileReadThreads</td><td>Maximum number of concurrent file reading threads.</td></tr>
* <tr><td>Process/MaxFileWriteThreads</td><td>Maximum number of concurrent file writing threads.</td></tr>
* <tr><td>Process/MaxUsageListLength</td><td>Maximum length of the <em>Recently Used</em> and <em>Most Used</em> lists on %Process %Explorer.</td></tr>
* <tr><td>System/NumberOfProcessors</td><td>Total number of processor cores available. Read-only.</td></tr>
* <tr><td>TransparencyBrush/Brush</td><td>See the pcl::BackgroundBrush namespace.</td></tr>
* <tr><td>Workspace/PrimaryScreenCenterX</td><td>Read-only. In physical device pixels.</td></tr>
* <tr><td>Workspace/PrimaryScreenCenterY</td><td>Read-only. In physical device pixels.</td></tr>
* <tr><td>Workspace/IconGridSpacing</td><td>Grid distance for aligned icon positions on all workspaces. In logical device pixels.</td></tr>
* </table>
*
* <h4>Global Reals</h4>
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>Application/StartJD</td><td>Starting time of the core application instance as a Julian day number. Read-only.</td></tr>
* <tr><td>Application/UIScalingFactor</td><td>Global interface scaling factor of the core application. In the range [1.0,4.0].</td></tr>
* <tr><td>ImageWindow/DefaultHorizontalResolution</td><td>In device pixels per resolution unit. See the ImageWindow/DefaultMetricResolution global variable.</td></tr>
* <tr><td>ImageWindow/DefaultVerticalResolution</td><td>In device pixels per resolution unit. See the ImageWindow/DefaultMetricResolution global variable.</td></tr>
* <tr><td>ImageWindow/PinchSensitivity</td><td>For touch events. In device pixels.</td></tr>
* <tr><td>MainWindow/ActiveWindowOpacity</td><td>Window opacity in the [0,1] range.</td></tr>
* <tr><td>MainWindow/AutoHideWindowOpacity</td><td>Window opacity in the [0,1] range.</td></tr>
* <tr><td>MainWindow/InactiveChildWindowOpacity</td><td>Window opacity in the [0,1] range.</td></tr>
* <tr><td>MainWindow/InactiveWindowOpacity</td><td>Window opacity in the [0,1] range.</td></tr>
* <tr><td>MainWindow/MovingChildWindowOpacity</td><td>Window opacity in the [0,1] range.</td></tr>
* <tr><td>MainWindow/MovingWindowOpacity</td><td>Window opacity in the [0,1] range.</td></tr>
* </table>
*
* <h4>Global Colors</h4>
*
* Since PixInsight core version 1.8.0, most UI colors and fonts are defined in
* cascading style sheet files loaded automatically on startup. Only the
* following four color variables remain because they are purely functional
* (i.e., not related to the appearance of GUI controls).
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>ColorManagement/GamutWarningColor</td><td>For signaling out-of-gamut pixels in color proofing image renditions.</td></tr>
* <tr><td>TransparencyBrush/BackgroundColor</td><td>Background brush color for renditions of translucent image pixels.</td></tr>
* <tr><td>TransparencyBrush/DefaultColor</td><td>Opaque color for renditions of translucent image pixels.</td></tr>
* <tr><td>TransparencyBrush/ForegroundColor</td><td>Foreground brush color for renditions of translucent image pixels.</td></tr>
* </table>
*
* <h4>Global Fonts</h4>
*
* Currently there are no global font variables. Since PixInsight core version
* 1.8.0, all UI fonts are defined through cascading style sheet files loaded
* automatically on startup.
*
* <h4>Global Strings</h4>
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>Application/AppDirectory</td><td>Full path to the distribution's core application bundle. Read-only. macOS only,</td></tr>
* <tr><td>Application/AsteroidEphemeridesFile</td><td>File name or path of the distribution's asteroid ephemerides file (XEPH format).</td></tr>
* <tr><td>Application/AsteroidEphemeridesFilePath</td><td>Full path to the current distribution's asteroid ephemerides file (XEPH format). Read-only.</td></tr>
* <tr><td>Application/BaseDirectory</td><td>Base directory of the core distribution. Read-only.</td></tr>
* <tr><td>Application/BinDirectory</td><td>Full path to the distribution's bin directory. Read-only.</td></tr>
* <tr><td>Application/CIP_ITRSDataFile</td><td>File name or path of the distribution's data file of CIP coordinates in the ITRS (plain text).</td></tr>
* <tr><td>Application/CIP_ITRSDataFilePath</td><td>Full path to the current distribution's data file of CIP coordinates in the ITRS (plain text). Read-only</td></tr>
* <tr><td>Application/CoreDirectory</td><td>Full directory of the core executable file. Read-only.</td></tr>
* <tr><td>Application/CoreFilePath</td><td>Full file path of the core executable. Read-only.</td></tr>
* <tr><td>Application/DeltaATDataFile</td><td>File name or path of the distribution's Delta AT (TAI-UTC) data file (plain text).</td></tr>
* <tr><td>Application/DeltaATDataFilePath</td><td>Full path to the current distribution's Delta AT (TAI-UTC) data file (plain text). Read-only</td></tr>
* <tr><td>Application/DeltaTDataFile</td><td>File name or path of the distribution's Delta T (TT-UT1) data file (plain text).</td></tr>
* <tr><td>Application/DeltaTDataFilePath</td><td>Full path to the current distribution's Delta T (TT-UT1) data file (plain text). Read-only</td></tr>
* <tr><td>Application/DocDirectory</td><td>Full path to the distribution's doc directory. Read-only.</td></tr>
* <tr><td>Application/EtcDirectory</td><td>Full path to the distribution's etc directory. Read-only.</td></tr>
* <tr><td>Application/FundamentalEphemeridesFile</td><td>File name or path of the distribution's fundamental ephemerides file (XEPH format).</td></tr>
* <tr><td>Application/FundamentalEphemeridesFilePath</td><td>Full path to the current distribution's fundamental ephemerides file (XEPH format). Read-only.</td></tr>
* <tr><td>Application/HighResFont</td><td>%Font family for automatic style sheet replacement on high-dpi displays.</td></tr>
* <tr><td>Application/HighResMonoFont</td><td>Monospaced font family for automatic style sheet replacement on high-dpi displays.</td></tr>
* <tr><td>Application/IncludeDirectory</td><td>Full path to the distribution's include directory. Read-only.</td></tr>
* <tr><td>Application/LibDirectory</td><td>Full path to the distribution's lib directory. Read-only.</td></tr>
* <tr><td>Application/LibraryDirectory</td><td>Full path to the distribution's library directory. Read-only.</td></tr>
* <tr><td>Application/LowResFont</td><td>%Font family for automatic style sheet replacement on low-dpi displays.</td></tr>
* <tr><td>Application/LowResMonoFont</td><td>Monospaced font family for automatic style sheet replacement on low-dpi displays.</td></tr>
* <tr><td>Application/NutationModelFile</td><td>File name or path of the distribution's nutation model file (XEPH format).</td></tr>
* <tr><td>Application/NutationModelFilePath</td><td>Full path to the current distribution's nutation model file (XEPH format). Read-only.</td></tr>
* <tr><td>Application/ResourceFile01</td><td>Core resource file #1.</td></tr>
* <tr><td>Application/ResourceFile02</td><td>Core resource file #2.</td></tr>
* <tr><td>Application/ResourceFile03</td><td>Core resource file #3.</td></tr>
* <tr><td>Application/ResourceFile04</td><td>Core resource file #4.</td></tr>
* <tr><td>Application/ResourceFile05</td><td>Core resource file #5.</td></tr>
* <tr><td>Application/ResourceFile06</td><td>Core resource file #6.</td></tr>
* <tr><td>Application/ResourceFile07</td><td>Core resource file #7.</td></tr>
* <tr><td>Application/ResourceFile08</td><td>Core resource file #8.</td></tr>
* <tr><td>Application/ResourceFile09</td><td>Core resource file #9.</td></tr>
* <tr><td>Application/ResourceFile10</td><td>Core resource file #10.</td></tr>
* <tr><td>Application/RscDirectory</td><td>Full path to the distribution's rsc directory. Read-only.</td></tr>
* <tr><td>Application/ShortTermAsteroidEphemeridesFile</td><td>File name or path of the distribution's asteroid ephemerides file (XEPH format) - short-term version (reduced time span).</td></tr>
* <tr><td>Application/ShortTermAsteroidEphemeridesFilePath</td><td>Full path to the current distribution's asteroid ephemerides file (XEPH format) - short-term version (reduced time span). Read-only.</td></tr>
* <tr><td>Application/ShortTermFundamentalEphemeridesFile</td><td>File name or path of the distribution's fundamental ephemerides file (XEPH format) - short-term version (reduced time span).</td></tr>
* <tr><td>Application/ShortTermFundamentalEphemeridesFilePath</td><td>Full path to the current distribution's fundamental ephemerides file (XEPH format) - short-term version (reduced time span). Read-only.</td></tr>
* <tr><td>Application/ShortTermNutationModelFile</td><td>File name or path of the distribution's nutation model file (XEPH format) - short-term version (reduced time span).</td></tr>
* <tr><td>Application/ShortTermNutationModelFilePath</td><td>Full path to the current distribution's nutation model file (XEPH format) - short-term version (reduced time span). Read-only.</td></tr>
* <tr><td>Application/SrcDirectory</td><td>Full path to the distribution's src directory. Read-only.</td></tr>
* <tr><td>Application/StartTime</td><td>Starting time of the core application in ISO 8601 extended format. Read-only.</td></tr>
* <tr><td>Application/StyleSheetFile</td><td>Main core stile sheet file.</td></tr>
* <tr><td>ColorManagement/DefaultGrayscaleProfilePath</td><td>Full path to the default ICC color profile for grayscale monochrome images.</td></tr>
* <tr><td>ColorManagement/DefaultRGBProfilePath</td><td>Full path to the default ICC color profile for RGB color images.</td></tr>
* <tr><td>ColorManagement/MonitorProfilePath</td><td>Full path to the ICC color profile associated with the primary monitor. Read-only.</td></tr>
* <tr><td>ColorManagement/ProofingProfilePath</td><td>Full path to the ICC color profile for the color proofing target device.</td></tr>
* <tr><td>ColorManagement/UpdateMonitorProfile</td><td>Full path to the scheduled new ICC color profile for the primary monitor. Write-only. See the documentation for ColorManagementSetup.</td></tr>
* <tr><td>FileFormat/ReadFilters</td><td>A list of file filters for file formats capable of image read operations, suitable for file dialogs. Read-only. Updated dynamically on-demand.</td></tr>
* <tr><td>FileFormat/WriteFilters</td><td>A list of file filters for file formats capable of image write operations, suitable for file dialogs. Read-only. Updated dynamically on-demand.</td></tr>
* <tr><td>ImageContainerIcon/Prefix</td><td>Prefix for automatically generated image container identifiers.</td></tr>
* <tr><td>ImageWindow/ClonePostfix</td><td>Postfix appended to image duplicates</td></tr>
* <tr><td>ImageWindow/DefaultFileExtension</td><td>The default file suffix used to save newly created images.</td></tr>
* <tr><td>ImageWindow/DownloadsDirectory</td><td>Full path to the core downloads directory.</td></tr>
* <tr><td>ImageWindow/NewImageCaption</td><td>Window title token for signaling newly created images.</td></tr>
* <tr><td>ImageWindow/Prefix</td><td>Prefix used for automatically generated image identifiers.</td></tr>
* <tr><td>ImageWindow/ProxyURL</td><td>The proxy that will be used for core network operations.</td></tr>
* <tr><td>MainWindow/WallpaperFile01</td><td>Core workspace wallpaper file #1.</td></tr>
* <tr><td>MainWindow/WallpaperFile02</td><td>Core workspace wallpaper file #2.</td></tr>
* <tr><td>MainWindow/WallpaperFile03</td><td>Core workspace wallpaper file #3.</td></tr>
* <tr><td>MainWindow/WallpaperFile04</td><td>Core workspace wallpaper file #4.</td></tr>
* <tr><td>MainWindow/WallpaperFile05</td><td>Core workspace wallpaper file #5.</td></tr>
* <tr><td>MainWindow/WallpaperFile06</td><td>Core workspace wallpaper file #6.</td></tr>
* <tr><td>MainWindow/WallpaperFile07</td><td>Core workspace wallpaper file #7.</td></tr>
* <tr><td>MainWindow/WallpaperFile08</td><td>Core workspace wallpaper file #8.</td></tr>
* <tr><td>MainWindow/WallpaperFile09</td><td>Core workspace wallpaper file #9.</td></tr>
* <tr><td>MainWindow/WallpaperFile10</td><td>Core workspace wallpaper file #10.</td></tr>
* <tr><td>Preview/Prefix</td><td>Prefix used for automatically generated preview identifiers.</td></tr>
* <tr><td>ProcessIcon/Prefix</td><td>Prefix used for automatically generated process icon identifiers.</td></tr>
* <tr><td>View/BrokenLinkText</td><td>Text fragment used to signal broken image and/or process relations, such as missing masks.</td></tr>
* <tr><td>ViewList/NoPreviewSelectedText</td><td>Text fragment used when there are no previews selected.</td></tr>
* <tr><td>ViewList/NoPreviewsAvailableText</td><td>Text fragment used when there are no previews available.</td></tr>
* <tr><td>ViewList/NoViewSelectedText</td><td>Text fragment used when there are no views selected.</td></tr>
* <tr><td>ViewList/NoViewsAvailableText</td><td>Text fragment used when there are no views available.</td></tr>
* <tr><td>Workspace/Prefix</td><td>Prefix used for automatically generated workspace identifiers.</td></tr>
* </table>
*/
class PCL_CLASS PixInsightSettings
{
public:
/*!
* Represents the data type of a global variable.
*/
typedef GlobalVariableType::value_type variable_type;
/*!
* Default constructor. This constructor is disabled because
* %PixInsightSettings is not an instantiable class.
*/
PixInsightSettings() = delete;
/*!
* Copy constructor. This constructor is disabled because
* %PixInsightSettings is not an instantiable class.
*/
PixInsightSettings( const PixInsightSettings& ) = delete;
/*!
* Copy assignment. This operator is disabled because
* %PixInsightSettings is not an instantiable class.
*/
PixInsightSettings& operator =( const PixInsightSettings& ) = delete;
/*!
* Virtual destructor. This destructor is disabled because
* %PixInsightSettings is not an instantiable class.
*/
virtual ~PixInsightSettings() = delete;
/*!
* Retrieves the type of a global variable \a globalId.
*/
static variable_type GlobalVariableType( const IsoString& globalId );
/*!
* Returns true iff the specified global variable \a globalId is defined in
* the current PixInsight platform.
*/
static bool IsGlobalVariableDefined( const IsoString& globalId )
{
return GlobalVariableType( globalId ) != GlobalVariableType::Undefined;
}
/*!
* Returns the value of a global boolean variable.
*/
static bool GlobalFlag( const IsoString& globalId );
/*!
* Returns the value of a global signed integer variable.
*/
static int GlobalInteger( const IsoString& globalId );
/*!
* Returns the value of a global unsigned integer variable.
*/
static unsigned GlobalUnsigned( const IsoString& globalId );
/*!
* Returns the value of a global floating point real variable.
*/
static double GlobalReal( const IsoString& globalId );
/*!
* Returns the value of a global RGBA color variable.
*/
static RGBA GlobalColor( const IsoString& globalId );
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
/*!
* Returns the value of a global font face variable.
*/
static Font GlobalFont( const IsoString& globalId );
#endif
/*!
* Returns the value of a global string variable.
*/
static String GlobalString( const IsoString& globalId );
/*!
* Begins a global variable update operation.
*
* \sa EndUpdate(), CalcelUpdate()
*/
static void BeginUpdate();
/*!
* Terminates a global variable update operation.
*
* \sa BeginUpdate(), CancelUpdate()
*/
static void EndUpdate();
/*!
* Aborts an ongoing global variable update operation.
*
* Use this function if you catch an exception during the sequence of
* SetGlobalXXX() calls. After cancelling an update operation, you
* shouldn't call EndUpdate().
*
* \sa BeginUpdate(), EndUpdate()
*/
static void CancelUpdate();
/*!
* Sets the value of a global boolean variable.
*/
static void SetGlobalFlag( const IsoString& globalId, bool );
/*!
* Sets the value of a global signed integer variable.
*/
static void SetGlobalInteger( const IsoString& globalId, int );
/*!
* Sets the value of a global unsigned integer variable.
*/
static void SetGlobalUnsigned( const IsoString& globalId, unsigned );
/*!
* Sets the value of a global floating point real variable.
*/
static void SetGlobalReal( const IsoString& globalId, double );
/*!
* Sets the value of a global RGBA color variable.
*/
static void SetGlobalColor( const IsoString& globalId, RGBA );
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
/*!
* Sets the value of a global font face variable.
*/
static void SetGlobalFont( const IsoString& globalId, const Font& );
#endif
/*!
* Sets the value of a global string variable.
*/
static void SetGlobalString( const IsoString& globalId, const String& );
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_GlobalSettings_h
// ----------------------------------------------------------------------------
// EOF pcl/GlobalSettings.h - Released 2022-03-12T18:59:29Z
-178
View File
@@ -1,178 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/GnomonicProjection.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_GnomonicProjection_h
#define __PCL_GnomonicProjection_h
/// \file pcl/GnomonicProjection.h
#include <pcl/Defs.h>
#include <pcl/ProjectionBase.h>
/*
* Based on original work contributed by Andrés del Pozo.
*/
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class GnomonicProjection
* \brief Gnomonic projection system
*
* \ingroup astrometry_support
*/
class PCL_CLASS GnomonicProjection : public ProjectionBase
{
public:
/*!
* Constructs a default %GnomonicProjection object with the specified
* origin equatorial coordinates \a ra0 and \a dec0 in degrees.
*/
GnomonicProjection( double ra0, double dec0 )
{
m_ra0 = Rad( ra0 );
m_dec0 = Rad( dec0 );
SinCos( m_dec0, m_sinDec0, m_cosDec0 );
}
/*!
* Constructs a %GnomonicProjection object with the specified \a scale
* factor and origin equatorial coordinates \a ra0 and \a dec0 in degrees.
*/
GnomonicProjection( double scale, double ra0, double dec0 )
: m_scale( scale )
{
m_ra0 = Rad( ra0 );
m_dec0 = Rad( dec0 );
SinCos( m_dec0, m_sinDec0, m_cosDec0 );
}
/*!
* Copy constructor.
*/
GnomonicProjection( const GnomonicProjection& ) = default;
/*!
* Returns a dynamically allocated duplicate of this object.
*/
ProjectionBase* Clone() const override
{
return new GnomonicProjection( *this );
}
/*!
* Returns the WCS projection identifier for this projection system.
*/
IsoString ProjCode() const override
{
return "TAN";
}
/*!
* Returns the readable name of this projection system.
*/
IsoString Name() const override
{
return "Gnomonic";
}
/*!
* Transforms from celestial coordinates to world coordinates.
*/
bool Direct( DPoint& pW, const DPoint& pRD ) const noexcept override;
/*!
* Transforms from world coordinates to celestial coordinates.
*/
bool Inverse( DPoint& pRD, const DPoint& pW ) const noexcept override;
/*!
*
*/
bool CheckBrokenLine( const DPoint& cp1, const DPoint& cp2 ) const noexcept override
{
DPoint gp1, gp2;
return Direct( gp1, cp1 ) && Direct( gp2, cp2 ) &&
(gp1.x - gp2.x)*(gp1.x - gp2.x) + (gp1.y - gp2.y)*(gp1.y - gp2.y) < 45*45;
}
protected:
bool Project( DPoint& pW, const DPoint& pN ) const noexcept override
{
return false;
}
bool Unproject( DPoint& pN, const DPoint& pW ) const noexcept override
{
return false;
}
private:
double m_scale = Const<double>::deg();
double m_sinDec0;
double m_cosDec0;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_GnomonicProjection_h
// ----------------------------------------------------------------------------
// EOF pcl/GnomonicProjection.h - Released 2022-03-12T18:59:29Z
-2329
View File
File diff suppressed because it is too large Load Diff
-987
View File
@@ -1,987 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/GridInterpolation.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_GridInterpolation_h
#define __PCL_GridInterpolation_h
/// \file pcl/GridInterpolation.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/AbstractImage.h>
#include <pcl/BicubicInterpolation.h>
#include <pcl/Matrix.h>
#include <pcl/ParallelProcess.h>
#include <pcl/Rectangle.h>
#include <pcl/ReferenceArray.h>
#include <pcl/Thread.h>
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
# include <pcl/Console.h>
# include <pcl/StandardStatus.h>
#endif
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class GridInterpolation
* \brief Discretized scalar surface interpolation/approximation in two
* dimensions.
*
* This class performs the same tasks as a surface interpolation device, such
* as SurfaceSpline or ShepardInterpolation, but allows for much faster
* interpolation with negligible accuracy loss in most applications.
*
* Interpolation from discrete grids can be orders of magnitude faster than
* direct evaluation of surface interpolation/approximation devices, depending
* on the number of input data points.
*/
class PCL_CLASS GridInterpolation : public ParallelProcess
{
public:
/*!
* Default constructor. Yields an empty instance that cannot be used without
* initialization.
*/
GridInterpolation() = default;
/*!
* Copy constructor.
*/
GridInterpolation( const GridInterpolation& ) = default;
/*!
* Move constructor.
*/
GridInterpolation( GridInterpolation&& ) = default;
/*!
* Copy assignment operator. Returns a reference to this object.
*/
GridInterpolation& operator =( const GridInterpolation& ) = default;
/*!
* Move assignment operator. Returns a reference to this object.
*/
GridInterpolation& operator =( GridInterpolation&& ) = default;
/*!
* Initializes this %GridInterpolation object for the specified input data
* and interpolation parameters.
*
* \param rect Reference rectangle. Interpolation will be initialized
* within the boundaries of this rectangle at discrete
* \a delta coordinate intervals.
*
* \param delta Grid distance for calculation of discrete function values.
* Must be > 0.
*
* \param S Reference to a surface interpolation/approximation object
* that will be used to evaluate function values at discrete
* coordinate intervals. This object must have been
* previously initialized and must be valid.
*
* \param verbose If true, this function will write information to the
* standard PixInsight console to provide some feedback to
* the user during the (potentially long) initialization
* process. If false, no feedback will be provided.
*
* The template parameter SI must provide a member function of the form:
*
* double SI::operator ()( int x, int y ) const
*
* or an equivalent operator member function whose return value can be
* statically casted to double, with two by-value parameters that can be
* statically casted from the int type. This function will be called
* multiple times to evaluate the approximated surface at discrete grid
* coordinate pairs {x,y}. The implementation of this member function must
* be thread-safe if parallel processing has been enabled and allowed for
* this object.
*
* If parallel processing is allowed, this function executes the
* initialization process using multiple concurrent threads. See
* EnableParallelProcessing() for additional information.
*/
template <class SI>
void Initialize( const Rect& rect, int delta, const SI& S, bool verbose = true )
{
PCL_PRECONDITION( rect.IsRect() )
PCL_PRECONDITION( delta > 0 )
m_rect = rect.Ordered();
if ( !m_rect.IsRect() )
throw Error( "GridInterpolation::Initialize(): Empty interpolation space." );
m_delta = Abs( delta );
if ( m_delta == 0 )
throw Error( "GridInterpolation::Initialize(): Zero grid distance." );
int w = rect.Width();
int h = rect.Height();
int rows = 1 + h/m_delta + ((h%m_delta) ? 1 : 0);
int cols = 1 + w/m_delta + ((w%m_delta) ? 1 : 0);
m_G = DMatrix( rows, cols );
StatusMonitor monitor;
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
StandardStatus status;
if ( verbose )
{
monitor.SetCallback( &status );
monitor.Initialize( "Building surface interpolation grid", rows );
}
#endif
Array<size_type> L = Thread::OptimalThreadLoads( rows,
1/*overheadLimit*/,
m_parallel ? m_maxProcessors : 1 );
AbstractImage::ThreadData data( monitor, rows );
ReferenceArray<GridInitializationThread<SI> > threads;
for ( int i = 0, n = 0; i < int( L.Length() ); n += int( L[i++] ) )
threads.Add( new GridInitializationThread<SI>( data, *this, S, n, n + int( L[i] ) ) );
AbstractImage::RunThreads( threads, data );
threads.Destroy();
m_I.Initialize( m_G.Begin(), cols, rows );
}
/*!
* Initializes this %GridInterpolation object with a prescribed discrete
* interpolation matrix.
*
* \param rect Reference rectangle. Interpolation will be initialized
* within the boundaries of this rectangle at discrete
* \a delta coordinate intervals.
*
* \param delta Grid distance for calculation of discrete function values.
* Must be > 0.
*
* \param G interpolation matrix.
*
* The specified \a G matrix must have \a n rows and \a m columns, which are
* given by:
*
* n = 1 + Ceil( rect.Height()/delta )\n
* m = 1 + Ceil( rect.Width()/delta )
*
* If the dimensions of the specified matrix are different from the values
* defined above, this function will throw an Error exception.
*
* Matrix elements must be function values computed at discrete \a delta
* intervals within \a rect boundaries. For a given matrix row \a r and
* matrix column \a c, the corresponding matrix element must be a function
* value computed at coordinates {\a x,\a y} given by:
*
* x = rect.x0 + c*delta\n
* y = rect.y0 + r*delta
*/
void Initialize( const Rect& rect, int delta, const DMatrix& G )
{
PCL_PRECONDITION( rect.IsRect() )
PCL_PRECONDITION( delta > 0 )
m_rect = rect.Ordered();
if ( !m_rect.IsRect() )
throw Error( "GridInterpolation::Initialize(): Empty interpolation space." );
m_delta = Abs( delta );
if ( m_delta == 0 )
throw Error( "GridInterpolation::Initialize(): Zero grid distance." );
int w = rect.Width();
int h = rect.Height();
int rows = 1 + h/m_delta + ((h%m_delta) ? 1 : 0);
int cols = 1 + w/m_delta + ((w%m_delta) ? 1 : 0);
if ( G.Rows() != rows || G.Cols() != cols )
throw Error( "GridInterpolation::Initialize(): Invalid matrix dimensions." );
m_G = G;
m_I.Initialize( m_G.Begin(), cols, rows );
}
/*!
* Returns true iff this is a valid, initialized object ready for
* interpolation.
*/
bool IsValid() const
{
return !m_G.IsEmpty();
}
/*!
* Deallocates internal structures, yielding an empty object that cannot be
* used before a new call to Initialize().
*/
void Clear()
{
m_I.Clear();
m_G.Clear();
}
/*!
* Returns the current interpolation reference rectangle. See Initialize()
* for more information.
*/
const Rect& ReferenceRect() const
{
return m_rect;
}
/*!
* Returns the current grid distance for calculation of discrete function
* values. See Initialize() for more information.
*/
int Delta() const
{
return m_delta;
}
/*!
* Returns a reference to the discrete matrix used for interpolation of
* function values.
*
* If this object has not been initialized, this member function returns a
* reference to an empty matrix.
*/
const DMatrix& InterpolationMatrix() const
{
return m_G;
}
/*!
* Returns an interpolated function value at the specified coordinates.
*/
template <typename T>
double operator ()( T x, T y ) const
{
double fx = (double( x ) - m_rect.x0)/m_delta;
double fy = (double( y ) - m_rect.y0)/m_delta;
return m_I( fx, fy );
}
/*!
* Returns an interpolated function value at \a p.x and \a p.y coordinates.
*/
template <typename T>
double operator ()( const GenericPoint<T>& p ) const
{
return operator ()( p.x, p.y );
}
private:
/*!
* N.B.: Here we need a smooth interpolation function without negative
* lobes, in order to prevent small-scale oscillations. Other options are
* BilinearInterpolation and CubicBSplineFilter.
*/
typedef BicubicBSplineInterpolation<double> grid_interpolation;
Rect m_rect;
int m_delta;
DMatrix m_G;
grid_interpolation m_I;
template <class SI>
class GridInitializationThread : public Thread
{
public:
GridInitializationThread( const AbstractImage::ThreadData& data,
GridInterpolation& grid, const SI& surface, int startRow, int endRow )
: m_data( data )
, m_grid( grid )
, m_surface( surface )
, m_startRow( startRow )
, m_endRow( endRow )
{
}
PCL_HOT_FUNCTION void Run() override
{
INIT_THREAD_MONITOR()
for ( int i = m_startRow, y = m_grid.m_rect.y0 + i*m_grid.m_delta; i < m_endRow; ++i, y += m_grid.m_delta )
{
for ( int j = 0, x = m_grid.m_rect.x0; j < m_grid.m_G.Cols(); ++j, x += m_grid.m_delta )
m_grid.m_G[i][j] = m_surface( x, y );
UPDATE_THREAD_MONITOR( 32 )
}
}
private:
const AbstractImage::ThreadData& m_data;
GridInterpolation& m_grid;
const SI& m_surface;
int m_startRow, m_endRow;
};
};
// ----------------------------------------------------------------------------
/*!
* \class PointGridInterpolation
* \brief Discretized vector surface interpolation/approximation in two
* dimensions.
*
* This class performs the same tasks as a point surface interpolation device,
* such as PointSurfaceSpline or PointShepardInterpolation, but allows for much
* faster interpolation with negligible accuracy loss in most applications.
*
* Interpolation from discrete grids can be orders of magnitude faster than
* direct evaluation of surface interpolation/approximation devices, depending
* on the number of input data points.
*/
class PCL_CLASS PointGridInterpolation : public ParallelProcess
{
public:
/*!
* Default constructor. Yields an empty instance that cannot be used without
* initialization.
*/
PointGridInterpolation() = default;
/*!
* Copy constructor.
*/
PointGridInterpolation( const PointGridInterpolation& ) = default;
/*!
* Move constructor.
*/
PointGridInterpolation( PointGridInterpolation&& ) = default;
/*!
* Copy assignment operator. Returns a reference to this object.
*/
PointGridInterpolation& operator =( const PointGridInterpolation& ) = default;
/*!
* Move assignment operator. Returns a reference to this object.
*/
PointGridInterpolation& operator =( PointGridInterpolation&& ) = default;
/*!
* Initializes a %PointGridInterpolation object with a point surface
* interpolation/approximation.
*
* \param rect Reference rectangle. Interpolation will be initialized
* within the boundaries of this rectangle at discrete
* \a delta coordinate intervals.
*
* \param delta Grid distance for calculation of discrete function values.
* Must be > 0.
*
* \param PS Reference to a point surface interpolation/approximation
* object that will be used to evaluate function values at
* discrete coordinate intervals. This object must have been
* previously initialized and must be valid.
*
* \param verbose If true, this function will write information to the
* standard PixInsight console to provide some feedback to
* the user during the (potentially long) initialization
* process. If false, no feedback will be provided.
*
* The template parameter PSI must provide a member function of the form:
*
* DPoint PSI::operator ()( int x, int y ) const
*
* or an equivalent operator member function whose return value can be
* statically casted to DPoint, with two by-value parameters that can be
* statically casted from the int type. This function will be called
* multiple times to evaluate the approximated surface at discrete grid
* coordinate pairs {x,y}. The implementation of this member function must
* be thread-safe if parallel processing has been enabled and allowed for
* this object.
*
* If parallel processing is allowed, this function executes the
* initialization process using multiple concurrent threads. See
* EnableParallelProcessing() for additional information.
*/
template <class PSI>
void Initialize( const Rect& rect, int delta, const PSI& PS, bool verbose = true )
{
PCL_PRECONDITION( rect.IsRect() )
PCL_PRECONDITION( delta > 0 )
m_rect = rect.Ordered();
if ( !m_rect.IsRect() )
throw Error( "PointGridInterpolation::Initialize(): Empty interpolation space." );
m_delta = Abs( delta );
if ( m_delta == 0 )
throw Error( "PointGridInterpolation::Initialize(): Zero grid distance." );
int w = rect.Width();
int h = rect.Height();
int rows = 1 + h/m_delta + ((h%m_delta) ? 1 : 0);
int cols = 1 + w/m_delta + ((w%m_delta) ? 1 : 0);
m_Gx = DMatrix( rows, cols );
m_Gy = DMatrix( rows, cols );
StatusMonitor monitor;
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
StandardStatus status;
if ( verbose )
{
monitor.SetCallback( &status );
monitor.Initialize( "Building surface interpolation grid", rows );
}
#endif
Array<size_type> L = Thread::OptimalThreadLoads( rows,
1/*overheadLimit*/,
m_parallel ? m_maxProcessors : 1 );
AbstractImage::ThreadData data( monitor, rows );
ReferenceArray<GridInitializationThread<PSI> > threads;
for ( int i = 0, n = 0; i < int( L.Length() ); n += int( L[i++] ) )
threads.Add( new GridInitializationThread<PSI>( data, *this, PS, n, n + int( L[i] ) ) );
AbstractImage::RunThreads( threads, data );
threads.Destroy();
m_Ix.Initialize( m_Gx.Begin(), cols, rows );
m_Iy.Initialize( m_Gy.Begin(), cols, rows );
}
/*!
* Initializes a %PointGridInterpolation object with separate surface
* interpolations/approximations for the X and Y directions.
*
* \param rect Reference rectangle. Interpolation will be initialized
* within the boundaries of this rectangle at discrete
* \a delta coordinate intervals.
*
* \param delta Grid distance for calculation of discrete function values.
* Must be > 0.
*
* \param Sx Reference to a surface interpolation/approximation object
* that will be used to evaluate function values at discrete
* coordinate intervals on the X axis. This object must have
* been previously initialized and must be valid.
*
* \param Sy Reference to a surface interpolation/approximation object
* that will be used to evaluate function values at discrete
* coordinate intervals on the Y axis. This object must have
* been previously initialized and must be valid.
*
* \param verbose If true, this function will write information to the
* standard PixInsight console to provide some feedback to
* the user during the (potentially long) initialization
* process. If false, no feedback will be provided.
*
* The template parameter SI must provide a member function of the form:
*
* double SI::operator ()( int x, int y ) const
*
* or an equivalent operator member function whose return value can be
* statically casted to double, with two by-value parameters that can be
* statically casted from the int type. This function will be called
* multiple times for the \a Sx and \a Sy objects to evaluate the
* approximated surface at discrete grid coordinate pairs {x,y},
* respectively on the X and Y plane directions. The implementation of this
* member function must be thread-safe if parallel processing has been
* enabled and allowed for this object.
*
* If parallel processing is allowed, this function executes the
* initialization process using multiple concurrent threads. See
* EnableParallelProcessing() for additional information.
*/
template <class SI>
void Initialize( const Rect& rect, int delta, const SI& Sx, const SI& Sy, bool verbose = true )
{
PCL_PRECONDITION( rect.IsRect() )
PCL_PRECONDITION( delta > 0 )
m_rect = rect.Ordered();
if ( !m_rect.IsRect() )
throw Error( "PointGridInterpolation::Initialize(): Empty interpolation space." );
m_delta = Abs( delta );
if ( m_delta == 0 )
throw Error( "PointGridInterpolation::Initialize(): Zero grid distance." );
int w = rect.Width();
int h = rect.Height();
int rows = 1 + h/m_delta + ((h%m_delta) ? 1 : 0);
int cols = 1 + w/m_delta + ((w%m_delta) ? 1 : 0);
m_Gx = DMatrix( rows, cols );
m_Gy = DMatrix( rows, cols );
StatusMonitor monitor;
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
StandardStatus status;
if ( verbose )
{
monitor.SetCallback( &status );
monitor.Initialize( "Building surface interpolation grid", rows );
}
#endif
Array<size_type> L = Thread::OptimalThreadLoads( rows,
1/*overheadLimit*/,
m_parallel ? m_maxProcessors : 1 );
AbstractImage::ThreadData data( monitor, rows );
ReferenceArray<GridInitializationXYThread<SI> > threads;
for ( int i = 0, n = 0; i < int( L.Length() ); n += int( L[i++] ) )
threads.Add( new GridInitializationXYThread<SI>( data, *this, Sx, Sy, n, n + int( L[i] ) ) );
AbstractImage::RunThreads( threads, data );
threads.Destroy();
m_Ix.Initialize( m_Gx.Begin(), cols, rows );
m_Iy.Initialize( m_Gy.Begin(), cols, rows );
}
/*!
* Initializes this %PointGridInterpolation object with prescribed
* interpolation matrices.
*
* \param rect Reference rectangle. Interpolation will be initialized
* within the boundaries of this rectangle at discrete
* \a delta coordinate intervals.
*
* \param delta Grid distance for calculation of discrete function values.
* Must be > 0.
*
* \param Gx interpolation matrix in the X direction.
*
* \param Gy Interpolation matrix in the Y direction.
*
* Both \a Gx and \a Gy matrices must have \a n rows and \a m columns, which
* are given by:
*
* n = 1 + Ceil( rect.Height()/delta )\n
* m = 1 + Ceil( rect.Width()/delta )
*
* If one or both matrices have different dimensions, this function will
* throw an Error exception.
*
* Matrix elements must be function values computed at discrete \a delta
* intervals within \a rect boundaries. For a given matrix row \a r and
* matrix column \a c, the corresponding matrix element must be a function
* value computed at coordinates {\a x,\a y} given by:
*
* x = rect.x0 + c*delta\n
* y = rect.y0 + r*delta
*/
void Initialize( const Rect& rect, int delta, const DMatrix& Gx, const DMatrix& Gy )
{
PCL_PRECONDITION( rect.IsRect() )
PCL_PRECONDITION( delta > 0 )
m_rect = rect.Ordered();
if ( !m_rect.IsRect() )
throw Error( "PointGridInterpolation::Initialize(): Empty interpolation space." );
m_delta = Abs( delta );
if ( m_delta == 0 )
throw Error( "PointGridInterpolation::Initialize(): Zero grid distance." );
int w = rect.Width();
int h = rect.Height();
int rows = 1 + h/m_delta + ((h%m_delta) ? 1 : 0);
int cols = 1 + w/m_delta + ((w%m_delta) ? 1 : 0);
if ( Gx.Rows() != rows || Gx.Cols() != cols || Gy.Rows() != rows || Gy.Cols() != cols )
throw Error( "PointGridInterpolation::Initialize(): Invalid matrix dimensions." );
m_Gx = Gx;
m_Gy = Gy;
m_Ix.Initialize( m_Gx.Begin(), cols, rows );
m_Iy.Initialize( m_Gy.Begin(), cols, rows );
}
/*!
*
*/
template <class PSI>
void ApplyLocalModel( const PSI& PS,
const String& message = "Applying local interpolation model",
bool verbose = true )
{
PCL_PRECONDITION( IsValid() )
if ( !IsValid() )
throw Error( "PointGridInterpolation::ApplyLocalModel(): Uninitialized interpolation." );
StatusMonitor monitor;
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
StandardStatus status;
if ( verbose )
{
monitor.SetCallback( &status );
monitor.Initialize( message, m_Gx.Rows() );
}
#endif
Array<size_type> L = Thread::OptimalThreadLoads( m_Gx.Rows(),
1/*overheadLimit*/,
m_parallel ? m_maxProcessors : 1 );
AbstractImage::ThreadData data( monitor, m_Gx.Rows() );
ReferenceArray<LocalModelThread<PSI> > threads;
for ( int i = 0, n = 0; i < int( L.Length() ); n += int( L[i++] ) )
threads.Add( new LocalModelThread<PSI>( data, *this, PS, n, n + int( L[i] ) ) );
AbstractImage::RunThreads( threads, data );
threads.Destroy();
}
/*!
*
*/
template <class SI>
void ApplyLocalModel( const SI& Sx, const SI& Sy,
const String& message = "Applying local interpolation model",
bool verbose = true )
{
PCL_PRECONDITION( IsValid() )
if ( !IsValid() )
throw Error( "PointGridInterpolation::ApplyLocalModel(): Uninitialized interpolation." );
StatusMonitor monitor;
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
StandardStatus status;
if ( verbose )
{
monitor.SetCallback( &status );
monitor.Initialize( message, m_Gx.Rows() );
}
#endif
Array<size_type> L = Thread::OptimalThreadLoads( m_Gx.Rows(),
1/*overheadLimit*/,
m_parallel ? m_maxProcessors : 1 );
AbstractImage::ThreadData data( monitor, m_Gx.Rows() );
ReferenceArray<LocalModelThread2<SI> > threads;
for ( int i = 0, n = 0; i < int( L.Length() ); n += int( L[i++] ) )
threads.Add( new LocalModelThread2<SI>( data, *this, Sx, Sy, n, n + int( L[i] ) ) );
AbstractImage::RunThreads( threads, data );
threads.Destroy();
}
/*!
* Returns true iff this is a valid, initialized object ready for
* interpolation.
*/
bool IsValid() const
{
return !m_Gx.IsEmpty() && !m_Gy.IsEmpty();
}
/*!
* Deallocates internal structures, yielding an empty object that cannot be
* used before a new call to Initialize().
*/
void Clear()
{
m_Ix.Clear();
m_Iy.Clear();
m_Gx.Clear();
m_Gy.Clear();
}
/*!
* Returns the current interpolation reference rectangle. See Initialize()
* for more information.
*
* The returned rectangle is ordered (see pcl::IsOrderedRect()).
*/
const Rect& ReferenceRect() const
{
return m_rect;
}
/*!
* Returns the current grid distance for calculation of discrete function
* values. See Initialize() for more information.
*/
int Delta() const
{
return m_delta;
}
/*!
* Returns a reference to the discrete matrix used for interpolation of
* function values in the X direction.
*
* If this object has not been initialized, this member function returns a
* reference to an empty matrix.
*/
const DMatrix& XInterpolationMatrix() const
{
return m_Gx;
}
/*!
* Returns a reference to the discrete matrix used for interpolation of
* function values in the Y direction.
*
* If this object has not been initialized, this member function returns a
* reference to an empty matrix.
*/
const DMatrix& YInterpolationMatrix() const
{
return m_Gy;
}
/*!
* Returns an interpolated point at the specified coordinates.
*/
template <typename T>
DPoint operator ()( T x, T y ) const
{
PCL_PRECONDITION( IsValid() )
double fx = (double( x ) - m_rect.x0)/m_delta;
double fy = (double( y ) - m_rect.y0)/m_delta;
return DPoint( m_Ix( fx, fy ), m_Iy( fx, fy ) );
}
/*!
* Returns an interpolated point at the given \a p.x and \a p.y coordinates.
*/
template <typename T>
DPoint operator ()( const GenericPoint<T>& p ) const
{
return operator ()( p.x, p.y );
}
private:
/*!
* N.B.: Here we need a smooth interpolation function without negative
* lobes, in order to prevent small-scale oscillations. Other options are
* BilinearInterpolation and CubicBSplineFilter.
*/
typedef BicubicBSplineInterpolation<double> grid_interpolation;
Rect m_rect;
int m_delta;
DMatrix m_Gx, m_Gy;
grid_interpolation m_Ix, m_Iy;
template <class PSI>
class GridInitializationThread : public Thread
{
public:
GridInitializationThread( const AbstractImage::ThreadData& data,
PointGridInterpolation& grid, const PSI& surface, int startRow, int endRow )
: m_data( data )
, m_grid( grid )
, m_surface( surface )
, m_startRow( startRow )
, m_endRow( endRow )
{
}
PCL_HOT_FUNCTION void Run() override
{
INIT_THREAD_MONITOR()
for ( int i = m_startRow, y = m_grid.m_rect.y0 + i*m_grid.m_delta; i < m_endRow; ++i, y += m_grid.m_delta )
{
for ( int j = 0, x = m_grid.m_rect.x0; j < m_grid.m_Gx.Cols(); ++j, x += m_grid.m_delta )
{
DPoint p = m_surface( x, y );
m_grid.m_Gx[i][j] = p.x;
m_grid.m_Gy[i][j] = p.y;
}
UPDATE_THREAD_MONITOR( 32 )
}
}
private:
const AbstractImage::ThreadData& m_data;
PointGridInterpolation& m_grid;
const PSI& m_surface;
int m_startRow, m_endRow;
};
template <class SI>
class GridInitializationXYThread : public Thread
{
public:
GridInitializationXYThread( const AbstractImage::ThreadData& data,
PointGridInterpolation& grid,
const SI& surfaceX, const SI& surfaceY, int startRow, int endRow )
: m_data( data )
, m_grid( grid )
, m_surfaceX( surfaceX )
, m_surfaceY( surfaceY )
, m_startRow( startRow )
, m_endRow( endRow )
{
}
PCL_HOT_FUNCTION void Run() override
{
INIT_THREAD_MONITOR()
for ( int i = m_startRow, y = m_grid.m_rect.y0 + i*m_grid.m_delta; i < m_endRow; ++i, y += m_grid.m_delta )
{
for ( int j = 0, x = m_grid.m_rect.x0; j < m_grid.m_Gx.Cols(); ++j, x += m_grid.m_delta )
{
m_grid.m_Gx[i][j] = m_surfaceX( x, y );
m_grid.m_Gy[i][j] = m_surfaceY( x, y );
}
UPDATE_THREAD_MONITOR( 32 )
}
}
private:
const AbstractImage::ThreadData& m_data;
PointGridInterpolation& m_grid;
const SI& m_surfaceX;
const SI& m_surfaceY;
int m_startRow, m_endRow;
};
template <class PSI>
class LocalModelThread : public Thread
{
public:
LocalModelThread( const AbstractImage::ThreadData& data,
PointGridInterpolation& grid, const PSI& model, int startRow, int endRow )
: m_data( data )
, m_grid( grid )
, m_model( model )
, m_startRow( startRow )
, m_endRow( endRow )
{
}
PCL_HOT_FUNCTION void Run() override
{
INIT_THREAD_MONITOR()
for ( int i = m_startRow, y = m_grid.m_rect.y0 + i*m_grid.m_delta; i < m_endRow; ++i, y += m_grid.m_delta )
{
for ( int j = 0, x = m_grid.m_rect.x0; j < m_grid.m_Gx.Cols(); ++j, x += m_grid.m_delta )
{
DPoint d = m_model( x, y );
m_grid.m_Gx[i][j] += d.x;
m_grid.m_Gy[i][j] += d.y;
}
UPDATE_THREAD_MONITOR( 32 )
}
}
private:
const AbstractImage::ThreadData& m_data;
PointGridInterpolation& m_grid;
const PSI& m_model;
int m_startRow, m_endRow;
};
template <class SI>
class LocalModelThread2 : public Thread
{
public:
LocalModelThread2( const AbstractImage::ThreadData& data,
PointGridInterpolation& grid, const SI& modelX, const SI& modelY, int startRow, int endRow )
: m_data( data )
, m_grid( grid )
, m_modelX( modelX )
, m_modelY( modelY )
, m_startRow( startRow )
, m_endRow( endRow )
{
}
PCL_HOT_FUNCTION void Run() override
{
INIT_THREAD_MONITOR()
for ( int i = m_startRow, y = m_grid.m_rect.y0 + i*m_grid.m_delta; i < m_endRow; ++i, y += m_grid.m_delta )
{
for ( int j = 0, x = m_grid.m_rect.x0; j < m_grid.m_Gx.Cols(); ++j, x += m_grid.m_delta )
{
m_grid.m_Gx[i][j] += m_modelX( x, y );
m_grid.m_Gy[i][j] += m_modelY( x, y );
}
UPDATE_THREAD_MONITOR( 32 )
}
}
private:
const AbstractImage::ThreadData& m_data;
PointGridInterpolation& m_grid;
const SI& m_modelX, m_modelY;
int m_startRow, m_endRow;
};
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_GridInterpolation_h
// ----------------------------------------------------------------------------
// EOF pcl/GridInterpolation.h - Released 2022-03-12T18:59:29Z
-175
View File
@@ -1,175 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/GroupBox.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_GroupBox_h
#define __PCL_GroupBox_h
/// \file pcl/GroupBox.h
#ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
#include <pcl/Defs.h>
#include <pcl/AutoPointer.h>
#include <pcl/Control.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class GroupBox
* \brief Client-side interface to a PixInsight %GroupBox control
*
* ### TODO: Write a detailed description for %GroupBox.
*/
class PCL_CLASS GroupBox : public Control
{
public:
/*!
* Constructs a %GroupBox object with the specified \a title, as a child
* control of \a parent.
*/
GroupBox( const String& title = String(), Control& parent = Control::Null() );
/*!
* Destroys a %GroupBox object.
*/
virtual ~GroupBox()
{
}
/*! #
*/
String Title() const;
/*! #
*/
void SetTitle( const String& );
/*! #
*/
bool HasTitleCheckBox() const;
/*! #
*/
void EnableTitleCheckBox( bool = true );
/*! #
*/
void DisableTitleCheckBox( bool disable = true )
{
EnableTitleCheckBox( !disable );
}
/*! #
*/
bool IsChecked() const;
/*! #
*/
void SetChecked( bool = true );
/*! #
*/
void Check()
{
SetChecked( true );
}
/*! #
*/
void Uncheck()
{
SetChecked( false );
}
// -------------------------------------------------------------------------
// Event handlers
//
// void OnCheck( GroupBox& sender, bool checked );
/*! #
*/
typedef void (Control::*check_event_handler)( GroupBox& sender, bool checked );
/*! #
*/
void OnCheck( check_event_handler, Control& );
private:
struct EventHandlers
{
check_event_handler onCheck = nullptr;
EventHandlers() = default;
EventHandlers( const EventHandlers& ) = default;
EventHandlers& operator =( const EventHandlers& ) = default;
};
AutoPointer<EventHandlers> m_handlers;
friend class GroupBoxEventDispatcher;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
#endif // __PCL_GroupBox_h
// ----------------------------------------------------------------------------
// EOF pcl/GroupBox.h - Released 2022-03-12T18:59:29Z
-132
View File
@@ -1,132 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/HammerAitoffProjection.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_HammerAitoffProjection_h
#define __PCL_HammerAitoffProjection_h
/// \file pcl/HammerAitoffProjection.h
#include <pcl/Defs.h>
#include <pcl/ProjectionBase.h>
/*
* Based on original work contributed by Andrés del Pozo.
*/
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class HammerAitoffProjection
* \brief Hammer-Aitoff projection system
*
* \ingroup astrometry_support
*/
class PCL_CLASS HammerAitoffProjection : public ProjectionBase
{
public:
/*!
* Default constructor.
*/
HammerAitoffProjection() = default;
/*!
* Copy constructor.
*/
HammerAitoffProjection( const HammerAitoffProjection& ) = default;
/*!
* Returns a dynamically allocated duplicate of this object.
*/
ProjectionBase* Clone() const override
{
return new HammerAitoffProjection( *this );
}
/*!
* Returns the WCS projection identifier for this projection system.
*/
IsoString ProjCode() const override
{
return "AIT";
}
/*!
* Returns the readable name of this projection system.
*/
IsoString Name() const override
{
return "Hammer-Aitoff";
}
protected:
bool Project( DPoint& pW, const DPoint& pN ) const noexcept override;
bool Unproject( DPoint& pN, const DPoint& pW ) const noexcept override;
private:
double m_Zmin = Const<double>::_1_sqrt2();
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_HammerAitoffProjection_h
// ----------------------------------------------------------------------------
// EOF pcl/HammerAitoffProjection.h - Released 2022-03-12T18:59:29Z
-660
View File
@@ -1,660 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Histogram.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Histogram_h
#define __PCL_Histogram_h
/// \file pcl/Histogram.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/ImageVariant.h>
#include <pcl/ParallelProcess.h>
#include <pcl/Vector.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class Histogram
* \brief Discrete image histogram function
*
* ### TODO: Write a detailed description for %Histogram.
*/
class PCL_CLASS Histogram : public ParallelProcess
{
public:
/*!
* Represents a histogram bin count, or the value of the discrete histogram
* function at a specific abscissa or range of abscissae.
*/
typedef uint64 count_type;
/*!
* A vector of histogram bin counts, which is the type used internally to
* store the values of the discrete histogram function.
*/
typedef UI64Vector histogram_type;
/*!
* Constructs an empty %Histogram object with the specified \a resolution.
*
* The resolution of a histogram function is the number of discrete
* intervals (or \e bins) used to analyze image data. The minimum possible
* resolution is 2. In PCL, the default resolution is 2^16 = 65536 intervals
* (also known as a <em>16-bit histogram</em>).
*/
Histogram( int resolution = 0x10000L )
: m_resolution( pcl::Max( 2, resolution ) )
{
PCL_PRECONDITION( resolution > 1 )
}
/*!
* Constructs a %Histogram object by importing a copy of the specified
* \a data vector as its internal vector of histogram function values.
* Automatically sets the histogram resolution equal to the length of the
* \a data vector, and calculates the peak level of the newly constructed
* histogram.
*
* If the specified \a data vector has less than two components, this
* constructor will yield an empty histogram with the default 16-bit
* resolution.
*/
Histogram( const histogram_type& data )
{
SetHistogramData( data );
}
/*!
* Copy constructor.
*/
Histogram( const Histogram& ) = default;
/*!
* Move constructor.
*/
Histogram( Histogram&& ) = default;
/*!
* Destroys a %Histogram object.
*/
virtual ~Histogram()
{
}
/*!
* Copy assignment operator. Returns a reference to this object.
*/
Histogram& operator =( const Histogram& ) = default;
/*!
* Move assignment operator. Returns a reference to this object.
*/
Histogram& operator =( Histogram&& ) = default;
/*!
* Assigns another %Histogram object \a x to this object.
*/
void Assign( const Histogram& x )
{
(void)operator =( x );
}
/*!
* Deallocates the internal vector of histogram values, yielding an empty
* %Histogram object.
*/
void Clear()
{
m_histogram.Clear();
m_peakLevel = 0;
}
/*!
* Returns true iff this %Histogram object is empty. An empty histogram has
* no computed histogram values.
*/
bool IsEmpty() const
{
return m_histogram.IsEmpty();
}
/*!
* Returns the current resolution of this %Histogram object.
*
* The resolution of a histogram function is the number of discrete
* intervals (or \e bins) used to analyze image data. The minimum possible
* resolution is 2. In PCL, the default resolution is 2^16 = 65536 intervals
* (also known as a <em>16-bit histogram</em>).
*/
int Resolution() const
{
return m_resolution;
}
/*!
* Returns the highest valid discrete histogram level, or Resolution()-1.
*/
int LastLevel() const
{
return m_resolution-1;
}
/*!
* Sets the resolution of this %Histogram object.
*
* The resolution of a histogram function is the number of discrete
* intervals (or \e bins) used to analyze image data. The minimum possible
* resolution is 2. In PCL, the default resolution is 2^16 = 65536 intervals
* (also known as a <em>16-bit histogram</em>).
*
* After calling this member function, the histogram will be empty and the
* internal vector of histogram function values will be deallocated.
*/
void SetResolution( int resolution )
{
PCL_PRECONDITION( resolution > 1 )
Clear();
m_resolution = pcl::Max( 2, resolution );
}
/*!
* If this histogram object is empty, this member function allocates the
* internal vector of histogram function values. Newly allocated vectors are
* not initialized, so the histogram will contain unpredictable values after
* calling this function.
*
* If the histogram is not empty, calling this function has no effect.
*/
void Allocate()
{
if ( m_histogram.IsEmpty() )
m_histogram = histogram_type( m_resolution );
}
/*!
* Returns the current peak level of the histogram. If this histogram is
* empty, the peak level is zero conventionally.
*
* The peak level is simply the index (or integer abscissa) of the histogram
* bin with the largest count, or the position on the X axis of the maximum
* of the histogram function, in the discrete range [0,LastLevel()].
*/
int PeakLevel() const
{
return m_histogram.IsEmpty() ? 0 : m_peakLevel;
}
/*!
* Returns the histogram peak level as a floating point number normalized to
* the [0,1] range. See PeakLevel().
*/
double NormalizedPeakLevel() const
{
return NormalizedLevel( PeakLevel() );
}
/*!
* Recalculates the histogram peak level from current histogram function
* values. If the histogram is empty, the peak level is reset to zero
* conventionally.
*
* Returns the newly calculated histogram peak level.
*/
int UpdatePeakLevel()
{
return m_peakLevel = m_histogram.IsEmpty() ? 0 :
int( pcl::MaxItem( m_histogram.Begin(), m_histogram.End() ) - m_histogram.Begin() );
}
/*!
* Returns the index of the discrete level in this %Histogram object
* corresponding to the specified normalized level \a x in the [0,1] range.
*/
int HistogramLevel( double x ) const
{
PCL_PRECONDITION( x >= 0 && x <= 1 )
return RoundInt( pcl::Range( x, 0.0, 1.0 )*(m_resolution - 1) );
}
/*!
* Returns the normalized histogram level in the [0,1] range corresponding
* to the specified discrete level \a i in this %Histogram object.
*/
double NormalizedLevel( int i ) const
{
PCL_PRECONDITION( i >= 0 && i < m_resolution )
return double( pcl::Range( i, 0, m_resolution-1 ) )/(m_resolution - 1);
}
/*!
* Converts the specified normalized levels \a a, \a b in the [0,1] range to
* discrete histogram levels \a i, \a j, respectively.
*/
void GetHistogramRange( int& i, int& j, double a, double b ) const
{
i = HistogramLevel( a );
j = HistogramLevel( b );
if ( j < i )
pcl::Swap( i, j );
}
/*!
* Converts the specified discrete histogram levels \a i, \a j to normalized
* levels \a a, \a b, respectively, in the [0,1] range.
*/
void GetNormalizedRange( double& a, double& b, int i, int j ) const
{
if ( j < i )
pcl::Swap( i, j );
a = NormalizedLevel( i );
b = NormalizedLevel( j );
}
/*!
* Returns the total sum of the counts in all histogram intervals, or the
* sum of all discrete histogram function values. If this %Histogram object
* is empty, this function returns zero.
*/
count_type Count() const
{
return m_histogram.Sum();
}
/*!
* Returns the histogram count, or the value of the histogram function, at
* the specified discrete level \a i.
*/
count_type Count( int i ) const
{
PCL_PRECONDITION( i >= 0 && i < m_histogram.Length() )
if ( i < 0 || i >= m_histogram.Length() )
return 0;
return m_histogram[i];
}
/*!
* Subscript operator. Equivalent to Count( int ).
*/
count_type operator []( int i ) const
{
return Count( i );
}
/*!
* Returns the sum of counts in the specified interval of discrete histogram
* levels \a i, \a j.
*/
count_type Count( int i, int j ) const
{
PCL_PRECONDITION( i >= 0 && i < m_histogram.Length() )
PCL_PRECONDITION( j >= 0 && j < m_histogram.Length() )
if ( m_histogram.IsEmpty() )
return 0;
i = pcl::Range( i, 0, m_histogram.Length()-1 );
j = pcl::Range( j, 0, m_histogram.Length()-1 );
if ( j < i )
pcl::Swap( i, j );
return pcl::Sum( m_histogram.At( i ), m_histogram.At( j+1 ) );
}
/*!
* Returns the histogram function value for the bin at the current peak
* level. Typically, the peak count is used to normalize the histogram to
* a prescribed range. For example, by dividing all histogram function
* values by the peak count the entire histogram will be normalized to the
* [0,1] range.
*/
count_type PeakCount() const
{
return Count( m_peakLevel );
}
/*!
* Returns the peak count, or the maximum histogram function value, within
* the specified range [i,j] of discrete histogram intervals.
*/
count_type PeakCount( int i, int j ) const
{
PCL_PRECONDITION( i >= 0 && i < m_histogram.Length() )
PCL_PRECONDITION( j >= 0 && j < m_histogram.Length() )
if ( m_histogram.IsEmpty() )
return 0;
i = pcl::Range( i, 0, m_histogram.Length()-1 );
j = pcl::Range( j, 0, m_histogram.Length()-1 );
if ( j < i )
pcl::Swap( i, j );
return *pcl::MaxItem( m_histogram.At( i ), m_histogram.At( j+1 ) );
}
/*!
* Returns the discrete histogram level where the sum of counts for its
* preceding levels is greater than or equal to the specified amount \a n.
*
* This function is useful to compute an automatic histogram shadows
* clipping point. The returned index is the position of the shadows
* clipping point that clips (sets to black) the specified amount of image
* pixel samples
*/
int ClipLow( count_type n ) const
{
int i = 0;
for ( count_type s = 0; i < m_histogram.Length()-1 && (s += m_histogram[i]) <= n; ++i ) {}
return i;
}
/*!
* Returns the normalized histogram level (in the [0,1] range) where the sum
* of counts for its preceding levels is greater than or equal to the
* specified amount \a n.
*/
double NormalizedClipLow( count_type n ) const
{
return NormalizedLevel( ClipLow( n ) );
}
/*!
* Returns the discrete histogram level where the sum of counts for its
* succeding levels is greater than or equal to the specified amount \a n.
*
* This function is useful to compute an automatic histogram highlights
* clipping point. The returned index is the position of the highlights
* clipping point that clips (sets to white) the specified amount of image
* pixel samples
*/
int ClipHigh( count_type n ) const
{
int i = m_histogram.Length();
for ( count_type s = 0; --i > 0 && (s += m_histogram[i]) <= n; ) {}
return i;
}
/*!
* Returns the normalized histogram level (in the [0,1] range) where the sum
* of counts for its succeding levels is greater than or equal to the
* specified amount \a n.
*/
double NormalizedClipHigh( count_type n ) const
{
return NormalizedLevel( ClipHigh( n ) );
}
/*!
* Returns a reference to the immutable internal vector of histogram
* function values.
*/
const histogram_type& HistogramData() const
{
return m_histogram;
}
/*!
* Causes this %Histogram object to import a copy of the specified \a data
* vector as its internal vector of histogram function values. Automatically
* sets the histogram resolution equal to the length of the \a data vector,
* and recalculates the peak level of the new histogram.
*
* If the specified \a data vector has less than two components, this member
* function will yield an empty histogram without changing the current
* histogram resolution.
*/
void SetHistogramData( const histogram_type& data )
{
if ( data.Length() < 2 )
Clear();
else
{
m_histogram = data;
m_resolution = m_histogram.Length();
UpdatePeakLevel();
}
}
/*!
* \deprecated This member function has been deprecated. It is kept as part
* of PCL for compatibility with existing modules; do not use it in newly
* produced code.
*/
void GetData( count_type* where, int fromLevel = 0, int toLevel = -1 ) const
{
PCL_PRECONDITION( where != nullptr )
PCL_PRECONDITION( fromLevel >= 0 )
if ( where != nullptr )
if ( !m_histogram.IsEmpty() )
{
fromLevel = pcl::Range( fromLevel, 0, m_histogram.Length()-1 );
toLevel = (toLevel < 0) ? m_histogram.Length()-1 : pcl::Range( toLevel, 0, m_histogram.Length()-1 );
if ( toLevel < fromLevel )
pcl::Swap( fromLevel, toLevel );
::memcpy( where, m_histogram.At( fromLevel ), (1+toLevel-fromLevel)*sizeof( count_type ) );
}
}
/*!
* Remaps the histogram function to fit the resolution of a target
* histogram \a h.
*
* If the target histogram has the same resolution as this object, this
* member function is equivalent to a plain assignment. If the resolutions
* differ, if this histogram is empty then the target histogram is
* deallocated and cleared, otherwise the target histogram is recomputed as
* a resampled version of this histogram.
*
* This member function is useful to generate reduced versions of a
* histogram. It can also be used to generate bootstrap samples from an
* existing histogram function.
*/
void Resample( Histogram& h ) const
{
if ( h.m_resolution == m_resolution )
h = *this;
else
{
if ( m_histogram.IsEmpty() )
h.Clear();
else
{
h.Allocate();
h.m_histogram = 0;
double k = double( h.m_histogram.Length() - 1 )/(m_histogram.Length() - 1);
for ( int i = 0; i < m_histogram.Length(); ++i )
h.m_histogram[pcl::RoundInt( i*k )] += m_histogram[i];
h.m_peakLevel = int( pcl::MaxItem( h.m_histogram.Begin(), h.m_histogram.End() ) - h.m_histogram.Begin() );
}
}
}
/*!
* Computes the discrete entropy of this histogram.
*
* The returned value is normalized to the total weight of the histogram,
* that is, it is independent on the total number of counts stored in the
* histogram data vector.
*/
double Entropy() const
{
double H = 0;
count_type n = Count();
if ( n > 0 )
for ( int i = 0; i < m_histogram.Length(); ++i )
if ( m_histogram[i] > 0 )
{
double f = double( m_histogram[i] )/n;
H -= f*Log( f );
}
return H;
}
/*!
* Computes the histogram function of a 32-bit floating point real image.
*/
const Image& operator <<( const Image& );
/*!
* Computes the histogram function of a 64-bit floating point real image.
*/
const DImage& operator <<( const DImage& );
/*!
* Computes the histogram function of an 8-bit unsigned integer image.
*/
const UInt8Image& operator <<( const UInt8Image& );
/*!
* Computes the histogram function of a 16-bit unsigned integer image.
*/
const UInt16Image& operator <<( const UInt16Image& );
/*!
* Computes the histogram function of a 32-bit unsigned integer image.
*/
const UInt32Image& operator <<( const UInt32Image& );
/*!
* Computes the histogram function of the image transported by an
* ImageVariant object.
*/
const ImageVariant& operator <<( const ImageVariant& );
/*!
* Returns the current rectangular selection in this %Histogram object.
*
* By default, the rectangular selection is an empy rectangle, meaning that
* the rectangular selection in the target image will be used.
*/
const Rect& SelectedRectangle() const
{
return m_rect;
}
/*!
* Sets a new rectangular selection for this %Histogram object.
*
* When a non-empty rectangular selection is specified, it is used as the
* region of interest (ROI) for calculation of histograms. If an empty or
* invalid rectangle is specified, the current selection in the target image
* will be used.
*/
void SelectRectangle( const Rect& r )
{
m_rect = r;
}
/*!
* Clears the rectangular selection in this %Histogram object.
*
* After calling this function, histograms will be calculated for the
* current rectangular selection of the target image.
*/
void ClearRectangle()
{
m_rect = Rect( 0 );
}
/*!
* Returns the current channel index selected in this %Histogram object.
*
* By default, the selected channel index is -1, meaning that the channel
* selected in the target image will be used.
*/
int SelectedChannel() const
{
return m_channel;
}
/*!
* Selects a channel index for this %Histogram object.
*
* When a positive (>= 0) channel index is specified, it is used for
* calculation of histograms. If a negative channel index is specified, the
* current selected channel in the target image will be used.
*/
void SelectChannel( int channel )
{
m_channel = pcl::Max( -1, channel );
}
/*!
* Clears the channel index selection in this %Histogram object.
*
* After calling this function, histograms will be calculated for the
* current selected channel of the target image.
*/
void ClearSelectedChannel()
{
m_channel = -1;
}
protected:
histogram_type m_histogram; // Discrete histogram levels
int m_resolution = 0x10000L; // Number of histogram levels
int m_peakLevel = 0; // Maximum level (index of maximum count)
Rect m_rect = 0; // ROI, Rect( 0 ) to use target image's selection
int m_channel = -1; // < 0 to use target image's selection
friend class View;
friend class HistogramTransformation;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_Histogram_h
// ----------------------------------------------------------------------------
// EOF pcl/Histogram.h - Released 2022-03-12T18:59:29Z
-530
View File
@@ -1,530 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/HistogramTransformation.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_HistogramTransformation_h
#define __PCL_HistogramTransformation_h
/// \file pcl/HistogramTransformation.h
#include <pcl/Defs.h>
#include <pcl/Array.h>
#include <pcl/ImageTransformation.h>
#include <pcl/ParallelProcess.h>
namespace pcl
{
// ----------------------------------------------------------------------------
class PCL_CLASS Histogram;
/*!
* \class HistogramTransformation
* \brief Multiple histogram transformation.
*
* ### TODO: Write a detailed description for %HistogramTransformation.
*/
class PCL_CLASS HistogramTransformation : public ImageTransformation, public ParallelProcess
{
public:
/*!
* Represents a set of chained histogram transformations.
*/
typedef Array<HistogramTransformation> transformation_list;
/*!
* Constructs a %HistogramTransformation object with the specified
* parameters.
*
* \param mb Midtones balance in the range [0,1].
*
* \param sc Shadows clipping point in the range [0,1].
*
* \param hc Highlights clipping point in the range [0,1].
*
* \param lr Low dynamic range expansion bound, \a lr &le; 0.
*
* \param hr High dynamic range expansion bound, \a hr &ge; 1.
*
* The default parameter values define an identity transformation:
*
* \a mb = 0.5, \a sc = 0, \a hc = 1, \a lr = 0, \a hr = 1.
*/
HistogramTransformation( double mb = 0.5,
double sc = 0, double hc = 1,
double lr = 0, double hr = 1 )
{
PCL_PRECONDITION( mb >= 0 && mb <= 1 )
PCL_PRECONDITION( sc >= 0 && sc <= 1 )
PCL_PRECONDITION( hc >= 0 && hc <= 1 )
PCL_PRECONDITION( lr <= 0 )
PCL_PRECONDITION( hr >= 1 )
m_midtonesBalance = pcl::Range( mb, 0.0, 1.0 );
m_clipLow = pcl::Range( sc, 0.0, 1.0 );
m_clipHigh = pcl::Range( hc, 0.0, 1.0 );
if ( m_clipHigh < m_clipLow )
pcl::Swap( m_clipLow, m_clipHigh );
m_expandLow = Min( lr, 0.0 );
m_expandHigh = Max( 1.0, hr );
UpdateFlags();
}
/*!
* Copy constructor.
*/
HistogramTransformation( const HistogramTransformation& ) = default;
/*!
* Move constructor.
*/
HistogramTransformation( HistogramTransformation&& ) = default;
/*!
* Destroys a %HistogramTransformation object.
*/
virtual ~HistogramTransformation()
{
}
/*!
* Copy assignment operator. Returns a reference to this object.
*/
HistogramTransformation& operator =( const HistogramTransformation& ) = default;
/*!
* Move assignment operator. Returns a reference to this object.
*/
HistogramTransformation& operator =( HistogramTransformation&& ) = default;
/*!
* Returns the number of histogram transforms in the transformation chain.
*/
size_type Length() const
{
return 1 + m_transformChain.Length();
}
/*!
* Returns a reference to the (immutable) transformation at the specified
* \a index in the current transformation chain.
*/
const HistogramTransformation& operator []( size_type index ) const
{
return (index == 0) ? *this : m_transformChain[index-1];
}
/*!
* Returns a reference to the (mutable) transformation at the specified
* \a index in this transformation chain.
*/
HistogramTransformation& operator []( size_type index )
{
return (index == 0) ? *this : m_transformChain[index-1];
}
/*!
* Returns a reference to the (immutable) first histogram transformation in
* the current chain. The returned value is always a reference to this
* object.
*/
const HistogramTransformation& operator *() const
{
return *this;
}
/*!
* Returns a reference to the (mutable) first histogram transformation in
* the current chain. The returned value is always a reference to this
* object.
*/
HistogramTransformation& operator *()
{
return *this;
}
/*!
* Adds a histogram transformation to the transformation chain of this
* %HistogramTransformation object.
*/
void Add( const HistogramTransformation& H )
{
m_transformChain.Add( H );
}
/*! #
*/
double MidtonesBalance() const
{
return m_midtonesBalance;
}
/*! #
*/
double ShadowsClipping() const
{
return m_clipLow;
}
/*! #
*/
double HighlightsClipping() const
{
return m_clipHigh;
}
/*! #
*/
double LowRange() const
{
return m_expandLow;
}
/*! #
*/
double HighRange() const
{
return m_expandHigh;
}
/*! #
*/
bool IsIdentityTransformation() const
{
return m_midtonesBalance == 0.5
&& m_clipLow == 0 && m_clipHigh == 1
&& m_expandLow == 0 && m_expandHigh == 1;
}
/*! #
*/
bool IsIdentityTransformationSet() const;
/*! #
*/
void SetMidtonesBalance( double b )
{
PCL_PRECONDITION( b >= 0 && b <= 1 )
m_midtonesBalance = pcl::Range( b, 0.0, 1.0 );
UpdateFlags();
}
/*! #
*/
void SetShadowsClipping( double c )
{
PCL_PRECONDITION( c >= 0 && c <= 1 )
m_clipLow = pcl::Range( c, 0.0, 1.0 );
if ( m_clipHigh < m_clipLow )
pcl::Swap( m_clipLow, m_clipHigh );
UpdateFlags();
}
/*! #
*/
void SetHighlightsClipping( double c )
{
PCL_PRECONDITION( c >= 0 && c <= 1 )
m_clipHigh = pcl::Range( c, 0.0, 1.0 );
if ( m_clipHigh < m_clipLow )
pcl::Swap( m_clipLow, m_clipHigh );
UpdateFlags();
}
/*! #
*/
void SetClipping( double sc, double hc )
{
PCL_PRECONDITION( sc >= 0 && sc <= 1 )
PCL_PRECONDITION( hc >= 0 && hc <= 1 )
m_clipLow = pcl::Range( sc, 0.0, 1.0 );
m_clipHigh = pcl::Range( hc, 0.0, 1.0 );
if ( m_clipHigh < m_clipLow )
pcl::Swap( m_clipLow, m_clipHigh );
UpdateFlags();
}
/*! #
*/
void SetLowRange( double r )
{
PCL_PRECONDITION( r <= 0 )
m_expandLow = Min( 0.0, r );
UpdateFlags();
}
/*! #
*/
void SetHighRange( double r )
{
PCL_PRECONDITION( r >= 1 )
m_expandHigh = Max( 1.0, r );
UpdateFlags();
}
/*! #
*/
void SetRange( double lr, double hr )
{
PCL_PRECONDITION( lr <= 0 )
PCL_PRECONDITION( hr >= 1 )
m_expandLow = Min( 0.0, lr );
m_expandHigh = Max( 1.0, hr );
UpdateFlags();
}
/*!
* Resets all transformation parameters to yield an identity histogram
* transformation.
*/
void Reset()
{
m_midtonesBalance = 0.5;
m_clipLow = 0;
m_clipHigh = 1;
m_expandLow = 0;
m_expandHigh = 1;
m_transformChain.Clear();
UpdateFlags();
}
// Avoid "hides virtual function in base" warnings by clang
using ImageTransformation::Apply;
/*! #
*/
void Apply( double*, size_type, double x0 = 0, double x1 = 1 ) const;
/*! #
*/
void Apply( float*, size_type, float x0 = 0, float x1 = 1 ) const;
/*! #
*/
void Apply( Histogram& dstH, const Histogram& srcH ) const;
/*! #
*/
void Make8BitLUT( uint8* ) const;
/*! #
*/
void Make16BitLUT( uint8* ) const;
/*! #
*/
void Make16BitLUT( uint16* ) const;
/*! #
*/
void Make20BitLUT( uint8* ) const;
/*! #
*/
void Make20BitLUT( uint16* ) const;
/*! #
*/
void Make24BitLUT( uint8* ) const;
/*! #
*/
void Make24BitLUT( uint16* ) const;
/*!
* Returns the value of the <em>midtones transfer function</em> (MTF) for a
* given midtones balance \a m and a sample point \a x. Both \a m and \a x
* must be in the range [0,1].
*/
static double MidtonesTransferFunction( double m, double x )
{
/*
* Bulirsch-Stoer algorithm for a diagonal rational interpolation
* function with three fixed data points: (0,0) (m,1/2) (1,1).
*
* This is the MTF function after direct substitution in the B-S
* equations:
*
* double r = 1 + 0.5/((x - m)/(x - 1)/2 - 1);
* return r + r/(x/(x - 1) * (1 - r/(r - 0.5)) - 1);
*
* We can simplify:
*
* double r = (m - 1)/(x + m - 2);
*
* and then we can further simplify to:
*
* return (m - 1)*x/((2*m - 1)*x - m);
*
* Finally, precalculating (m - 1) we can save a multiplication.
*/
if ( x > 0 ) // guard us against degenerate cases
{
if ( x < 1 )
{
double m1 = m - 1;
return m1*x/((m + m1)*x - m);
}
return 1;
}
return 0;
}
/*!
* A convenience synonym for MidtonesTransferFunction( m, x ).
*/
static double MTF( double m, double x )
{
return MidtonesTransferFunction( m, x );
}
/*!
* Transforms a real \a value in the normalized [0,1] range.
*/
void Transform( double& value ) const
{
if ( m_flags.hasClipping )
value = m_flags.hasDelta ? ((value <= m_clipLow) ? 0.0 : ((value >= m_clipHigh) ? 1.0 : (value - m_clipLow)/m_flags.d)) : m_clipLow;
if ( m_flags.hasMTF )
value = HistogramTransformation::MTF( m_midtonesBalance, value );
if ( m_flags.hasRange )
value = (value - m_expandLow)/m_flags.dr;
}
/*!
* \struct pcl::HistogramTransformation::Flags
* \brief Characterizes a histogram transformation pertaining to a
* histogram transformation chain.
*/
struct Flags
{
double d = 1.0; //!< Total width of the stretched dynamic range
double dr = 1.0; //!< Total width of the expanded dynamic range
bool hasClipping = false; //!< The transformation defines clipping parameters
bool hasMTF = false; //!< The transformation defines a midtones transfer function
bool hasRange = false; //!< The transformation defines dynamic range expansion parameters
bool hasDelta = false; //!< The transformation defines a nonzero stretched range of sample values
/*!
* Default constructor.
*/
Flags() = default;
/*!
* Copy constructor.
*/
Flags( const Flags& ) = default;
/*!
* Constructs a new %Flags object initialized for the parameters of the
* specified HistogramTransformation \a H.
*/
Flags( const HistogramTransformation& H )
{
hasClipping = H.m_clipLow != 0 || H.m_clipHigh != 1;
hasMTF = H.m_midtonesBalance != 0.5;
hasRange = H.m_expandLow != 0 || H.m_expandHigh != 1;
hasDelta = false;
if ( hasClipping )
{
d = H.m_clipHigh - H.m_clipLow;
hasDelta = 1 + d != 1;
}
if ( hasRange )
dr = H.m_expandHigh - H.m_expandLow;
}
};
/*!
* Returns the set of flags characterizing this histogram transformation.
*/
Flags TransformationFlags() const
{
return m_flags;
}
private:
double m_midtonesBalance = 0.5; // midtones balance
double m_clipLow = 0; // shadows clipping point
double m_clipHigh = 1; // highlights clipping point
double m_expandLow = 0; // shadows dynamic range expansion
double m_expandHigh = 1; // highlights dynamic range expansion
Flags m_flags; // transformation flags
transformation_list m_transformChain; // more transformations
/*!
* \internal
*/
void UpdateFlags()
{
m_flags = Flags( *this );
}
void Apply( pcl::Image& ) const override;
void Apply( pcl::DImage& ) const override;
void Apply( pcl::UInt8Image& ) const override;
void Apply( pcl::UInt16Image& ) const override;
void Apply( pcl::UInt32Image& ) const override;
friend class LUT2408Thread;
friend class LUT2416Thread;
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_HistogramTransformation_h
// ----------------------------------------------------------------------------
// EOF pcl/HistogramTransformation.h - Released 2022-03-12T18:59:29Z
-406
View File
@@ -1,406 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/Homography.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_Homography_h
#define __PCL_Homography_h
/// \file pcl/Homography.h
#include <pcl/Defs.h>
#include <pcl/Diagnostics.h>
#include <pcl/Algebra.h>
#include <pcl/Array.h>
#include <pcl/Matrix.h>
#include <pcl/Point.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class Homography
* \brief Homography geometric transformation.
*
* A two-dimensional projective transformation, or \e homography, is a
* line-preserving geometric transformation between two sets of points in the
* plane. More formally, if P represents the set of points in the plane, a
* homography is an invertible mapping H from P^2 to itself such that three
* points p1, p2, p3 are collinear if and only if H(p1), H(p2), H(p3) do.
*
* Homographies have important practical applications in the field of computer
* vision. On the PixInsight platform, this class is an essential component of
* image registration and astrometry processes.
*/
template <class P = DPoint>
class PCL_CLASS Homography
{
public:
/*!
* Represents a reference point in two dimensions.
*/
typedef P point;
/*!
* Represents a list of two-dimensional reference points involved in a
* homography transformation.
*/
typedef Array<point> point_list;
/*!
* Default constructor. Constructs a no-op transformation with a unit matrix
* transformation matrix.
*/
Homography()
: m_H( Matrix::UnitMatrix( 3 ) )
{
}
/*!
* Constructor from a given homography matrix.
*/
Homography( const Matrix& H )
: m_H( H )
{
}
/*!
* Constructor from two 2D point lists.
*
* Computes a homography transformation to generate a list \a P2 of
* transformed points from a list \a P1 of original points. In other words,
* the computed homography H works as follows:
*
* P2 = H( P1 )
*
* The transformation matrix is calculated by the Direct Linear
* Transformation (DLT) method. Both point lists must contain at least four
* points.
*
* If one of the specified point lists contains less than four points, or if
* no homography can be estimated from the specified point lists (which
* leads to a singular transformation matrix), this constructor throws an
* appropriate Error exception.
*
* \b References
*
* R. Hartley, <em>In defense of the eight-point algorithm.</em> IEEE
* Transactions on Pattern Analysis and Machine Intelligence, vol. 19, pp.
* 580593, June 1997.
*/
Homography( const point_list& P1, const point_list& P2 )
: m_H( DLT( P1, P2 ) )
{
}
/*!
* Copy constructor.
*/
Homography( const Homography& ) = default;
/*!
* Copy assignment operator.
*/
Homography& operator =( const Homography& ) = default;
/*!
* Move constructor.
*/
Homography( Homography&& ) = default;
/*!
* Move assignment operator.
*/
Homography& operator =( Homography&& ) = default;
/*!
* Coordinate transformation operator. Applies the homography matrix to the
* specified \a x and \a y coordinates. Returns the transformed point as a
* two-dimensional point with real coordinates.
*/
template <typename T>
DPoint operator ()( T x, T y ) const
{
double w = m_H[2][0]*x + m_H[2][1]*y + m_H[2][2];
PCL_CHECK( 1 + w != 1 )
return DPoint( (m_H[0][0]*x + m_H[0][1]*y + m_H[0][2])/w,
(m_H[1][0]*x + m_H[1][1]*y + m_H[1][2])/w );
}
/*!
* Point transformation operator. Applies the homography matrix to the
* coordinates of the specified point \a p. Returns the transformed point as
* a two-dimensional point with real coordinates.
*/
template <typename T>
DPoint operator ()( const GenericPoint<T>& p ) const
{
return operator ()( p.x, p.y );
}
/*!
* Returns the inverse of this homography transformation.
*
* If this transformation has been computed from two point lists \a P1 and
* \a P2:
*
* P2 = H( P1 )
*
* then this function returns a transformation H1 such that:
*
* P1 = H1( P2 )
*/
Homography Inverse() const
{
return Homography( m_H.Inverse() );
}
/*!
* Returns the homography transformation matrix.
*/
operator const Matrix&() const
{
return m_H;
}
/*!
* Returns true iff this transformation has been initialized and is valid.
*/
bool IsValid() const
{
return !m_H.IsEmpty();
}
/*!
* Returns true iff this is an affine homography transformation.
*
* An affine homography is a special type of a general homography where the
* last row of the 3x3 transformation matrix is equal to (0, 0, 1). This
* function verifies that this property holds for the current transformation
* matrix (if it is valid) up to the machine epsilon for the \c double
* numeric type.
*/
bool IsAffine() const
{
return IsValid()
&& Abs( m_H[2][0] ) <= std::numeric_limits<double>::epsilon()
&& Abs( m_H[2][1] ) <= std::numeric_limits<double>::epsilon()
&& 1 - Abs( m_H[2][2] ) <= std::numeric_limits<double>::epsilon();
}
/*!
* Ensures that the transformation uniquely references its internal matrix
* data.
*/
void EnsureUnique()
{
m_H.EnsureUnique();
}
private:
Matrix m_H;
/*
* Normalization of reference points.
*/
struct NormalizedPoints
{
Array<DPoint> N; // the normalized points
Matrix T; // 3x3 normalization matrix
NormalizedPoints( const point_list& points )
{
/*
* Calculate the centroid of the input set of points.
*/
DPoint centroid( 0 );
for ( const auto& p : points )
centroid += p;
centroid /= points.Length();
/*
* Calculate mean centroid distance and move origin to the centroid.
*/
double d0 = 0;
for ( const auto& p : points )
{
double x = p.x - centroid.x;
double y = p.y - centroid.y;
N << DPoint( x, y );
d0 += Sqrt( x*x + y*y );
}
d0 /= points.Length();
/*
* Scale point coordinates.
*/
double scale = Const<double>::sqrt2()/d0;
for ( auto& p : N )
p *= scale;
/*
* Form the normalization matrix.
*/
T = Matrix( scale, 0.0, -scale*centroid.x,
0.0, scale, -scale*centroid.y,
0.0, 0.0, 1.0 );
}
};
/*
* Implementation of the Direct Linear Transformation (DLT) method to
* compute a normalized homography matrix.
*/
static Matrix DLT( const point_list& P1, const point_list& P2 )
{
int n = Min( P1.Length(), P2.Length() );
if ( n < 4 )
throw Error( "Homography::DLT(): Less than four points specified." );
/*
* Normalize all points.
*/
NormalizedPoints p1( P1 );
NormalizedPoints p2( P2 );
/*
* Setup cross product matrix A.
*/
Matrix A( 2*n, 9 );
for ( int i = 0; i < n; ++i )
{
double x1 = p1.N[i].x;
double y1 = p1.N[i].y;
double x2 = p2.N[i].x;
double y2 = p2.N[i].y;
double* A0 = A[2*i];
double* A1 = A[2*i + 1];
//double* A2 = A[3*i + 2]; <-- linearly dependent eqn.
A0[0] = A0[1] = A0[2] = 0;
A0[3] = -x1;
A0[4] = -y1;
A0[5] = -1;
A0[6] = y2*x1;
A0[7] = y2*y1;
A0[8] = y2;
A1[0] = x1;
A1[1] = y1;
A1[2] = 1;
A1[3] = A1[4] = A1[5] = 0;
A1[6] = -x2*x1;
A1[7] = -x2*y1;
A1[8] = -x2;
/* <-- linearly dependent eqn.
A2[0] = -y2*x1;
A2[1] = -y2*y1;
A2[2] = -y2;
A2[3] = x2*x1;
A2[4] = x2*y1;
A2[5] = x2;
A2[6] = A2[7] = A2[8] = 0;
*/
}
/*
* SVD of cross product matrix.
*/
InPlaceSVD svd( A );
/*
* For sanity, set to zero all insignificant singular values.
*/
for ( int i = 0; i < svd.W.Length(); ++i )
if ( Abs( svd.W[i] ) <= std::numeric_limits<double>::epsilon() )
svd.W[i] = 0;
/*
* Locate the smallest nonzero singular value.
*/
int i = svd.IndexOfSmallestSingularValue();
/*
* The components of the homography matrix are those of the smallest
* eigenvector, i.e. the column vector of V corresponding to the smallest
* singular value.
*/
Matrix H( svd.V[0][i], svd.V[1][i], svd.V[2][i],
svd.V[3][i], svd.V[4][i], svd.V[5][i],
svd.V[6][i], svd.V[7][i], svd.V[8][i] );
if ( Abs( H[2][2] ) <= std::numeric_limits<double>::epsilon() )
throw Error( "Homography::DLT(): Singular matrix." );
/*
* Denormalize matrix components.
*/
H = p2.T.Inverse() * H * p1.T;
/*
* Normalize matrix so that H[2][2] = 1.
*/
return H *= 1/H[2][2];
}
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_Homography_h
// ----------------------------------------------------------------------------
// EOF pcl/Homography.h - Released 2022-03-12T18:59:29Z
-905
View File
@@ -1,905 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/ICCProfile.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_ICCProfile_h
#define __PCL_ICCProfile_h
/// \file pcl/ICCProfile.h
#include <pcl/Defs.h>
#include <pcl/ByteArray.h>
#include <pcl/Flags.h>
#include <pcl/StringList.h>
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \defgroup color_management Color Management Classes
*/
/*!
* \namespace pcl::ICCProfileClass
* \brief Representation of ICC color profile classes
* \ingroup color_management
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>ICCProfileClass::Unknown</td> <td>Unknown or unsupported ICC profile class</td></tr>
* <tr><td>ICCProfileClass::Any</td> <td>Any ICC profile class</td></tr>
* <tr><td>ICCProfileClass::InputDevice</td> <td>Input device (scanner) profile</td></tr>
* <tr><td>ICCProfileClass::DisplayDevice</td> <td>Display device (monitor) profile</td></tr>
* <tr><td>ICCProfileClass::OutputDevice</td> <td>Output device (printer) profile</td></tr>
* <tr><td>ICCProfileClass::DeviceLink</td> <td>Device link profile</td></tr>
* <tr><td>ICCProfileClass::ColorSpaceConversion</td> <td>Color space conversion profile</td></tr>
* <tr><td>ICCProfileClass::AbstractProfile</td> <td>Abstract profile</td></tr>
* <tr><td>ICCProfileClass::NamedColorProfile</td> <td>Named color profile</td></tr>
* </table>
*/
namespace ICCProfileClass
{
enum mask_type
{
Unknown = 0x80000000,
Any = 0x00000000,
InputDevice = 0x00000001,
DisplayDevice = 0x00000002,
OutputDevice = 0x00000004,
DeviceLink = 0x00000008,
ColorSpaceConversion = 0x00000010,
AbstractProfile = 0x00000020,
NamedColorProfile = 0x00000040
};
}
/*!
* \class pcl::ICCProfileClasses
* \brief A combination of ICCProfileClass values.
* \ingroup color_management
*/
typedef Flags<ICCProfileClass::mask_type> ICCProfileClasses;
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::ICCColorSpace
* \brief Representation of data and connection color spaces in ICC color profiles.
* \ingroup color_management
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>ICCColorSpace::Unknown</td> <td>Unknown or unsupported color space</td></tr>
* <tr><td>ICCColorSpace::Any</td> <td>Any color space in an ICC profile</td></tr>
* <tr><td>ICCColorSpace::XYZ</td> <td>CIE XYZ color space</td></tr>
* <tr><td>ICCColorSpace::Lab</td> <td>CIE L*a*b* color space</td></tr>
* <tr><td>ICCColorSpace::Luv</td> <td>CIE L*u*v* color space</td></tr>
* <tr><td>ICCColorSpace::YCbCr</td> <td>YCbCr color space</td></tr>
* <tr><td>ICCColorSpace::Yxy</td> <td>Yxy (luminance and chromaticity coordinates)</td></tr>
* <tr><td>ICCColorSpace::RGB</td> <td>RGB color space</td></tr>
* <tr><td>ICCColorSpace::Gray</td> <td>Grayscale color space</td></tr>
* <tr><td>ICCColorSpace::HSV</td> <td>HSV color ordering system</td></tr>
* <tr><td>ICCColorSpace::HLS</td> <td>HLS color ordering system</td></tr>
* <tr><td>ICCColorSpace::CMYK</td> <td>CMYK color space</td></tr>
* <tr><td>ICCColorSpace::CMY</td> <td>CMY color space</td></tr>
* <tr><td>ICCColorSpace::LuvK</td> <td>LuvK color space</td></tr>
* </table>
*
* Other color spaces supported by the ICC profile specification, as for
* example 2-color and 15-color spaces, are unknown to this implementation.
*/
namespace ICCColorSpace
{
enum mask_type
{
Unknown = 0x80000000,
Any = 0x00000000,
XYZ = 0x00000001,
Lab = 0x00000002,
Luv = 0x00000004,
YCbCr = 0x00000008,
Yxy = 0x00000010,
RGB = 0x00000020,
Gray = 0x00000040,
HSV = 0x00000080,
HLS = 0x00000100,
CMYK = 0x00000200,
CMY = 0x00000400,
LuvK = 0x00000800
};
}
/*!
* \class pcl::ICCColorSpaces
* \brief A combination of ICCColorSpace values.
* \ingroup color_management
*/
typedef Flags<ICCColorSpace::mask_type> ICCColorSpaces;
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::ICCRenderingIntent
* \brief ICC rendering intents
* \ingroup color_management
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>ICCRenderingIntent::Perceptual</td> <td>Perceptual rendering intent (photographic images)</td></tr>
* <tr><td>ICCRenderingIntent::Saturation</td> <td>Saturation rendering intent (graphics)</td></tr>
* <tr><td>ICCRenderingIntent::RelativeColorimetric</td> <td>Relative colorimetric rendering intent (match white points)</td></tr>
* <tr><td>ICCRenderingIntent::AbsoluteColorimetric</td> <td>Absolute colorimetric rendering intent (proofing)</td></tr>
* </table>
*/
namespace ICCRenderingIntent
{
enum value_type
{
Perceptual,
Saturation,
RelativeColorimetric,
AbsoluteColorimetric
};
}
// ----------------------------------------------------------------------------
/*!
* \namespace pcl::ICCRenderingDirection
* \brief ICC transform rendering direction
* \ingroup color_management
*
* <table border="1" cellpadding="4" cellspacing="0">
* <tr><td>ICCRenderingDirection::Input</td> <td>Denotes a rendering intent applied to input pixel values.</td></tr>
* <tr><td>ICCRenderingDirection::Output</td> <td>Denotes a rendering intent applied to output pixel values.</td></tr>
* <tr><td>ICCRenderingDirection::Proofing</td> <td>Denotes a rendering intent applied by a proofing transform.</td></tr>
* </table>
*/
namespace ICCRenderingDirection
{
enum value_type
{
Input,
Output,
Proofing
};
}
// ----------------------------------------------------------------------------
/*!
* \class ICCProfile
* \brief A high-level interface to ICC color profiles
*
* %ICCProfile is a high-level interface to the ICC profile handling
* functionality implemented in the PixInsight core application. An instance of
* %ICCProfile transports an ICC profile structure that can be embedded in
* image files or used to build color management transformations with the
* ICCProfileTransformation class.
*
* %ICCProfile implements a set of utility functions for profile validation,
* profile information retrieval, profile disk I/O and profile directory
* search, among other tasks.
*
* \ingroup color_management
* \sa ICCProfileTransformation
*/
class PCL_CLASS ICCProfile
{
public:
/*!
* Represents an opaque handle to an internal ICC profile.
*/
typedef void* handle;
/*!
* Represents an ICC profile device class.
*/
typedef ICCProfileClass::mask_type profile_class;
/*!
* Represents an ICC profile color space.
*/
typedef ICCColorSpace::mask_type color_space;
/*!
* Represents an ICC rendering intent.
*/
typedef ICCRenderingIntent::value_type rendering_intent;
/*!
* Represents an ICC transform rendering direction.
*/
typedef ICCRenderingDirection::value_type rendering_direction;
/*!
* Constructs an empty %ICCProfile object. An empty %ICCProfile doesn't
* store an ICC profile structure.
*/
ICCProfile() = default;
/*!
* Copy constructor.
*/
ICCProfile( const ICCProfile& ) = default;
/*!
* Move constructor.
*/
ICCProfile( ICCProfile&& ) = default;
/*!
* Constructs an %ICCProfile object and loads an ICC profile from a file at
* the specified \a profilePath.
*
* If the specified file does not exist, is not readable, or does not
* contain a valid ICC profile structure, this constructor throws an Error
* exception.
*/
ICCProfile( const String& profilePath )
{
Load( profilePath );
}
/*!
* Constructs an %ICCProfile object to store a copy of the raw ICC profile
* structure available in the specified container. This constructor simply
* calls Set( rawData ).
*/
ICCProfile( const ByteArray& rawData )
{
Set( rawData );
}
/*!
* Constructs an %ICCProfile object to store a copy of the raw ICC profile
* structure at the specified location. This constructor simply calls
* Set( rawData ).
*/
ICCProfile( const void* rawData )
{
Set( rawData );
}
/*!
* Destroys an %ICCProfile object. If this object stores an ICC profile
* structure, it is deallocated upon destruction.
*/
virtual ~ICCProfile()
{
}
/*!
* Copy assignment operator. Returns a reference to this object.
*/
ICCProfile& operator =( const ICCProfile& ) = default;
/*!
* Move assignment operator. Returns a reference to this object.
*/
ICCProfile& operator =( ICCProfile&& ) = default;
/*!
* Returns true iff this object stores an ICC color profile structure.
*/
bool IsProfile() const
{
return !m_data.IsEmpty();
}
/*!
* A convenience synonym for IsProfile().
*/
operator bool() const
{
return IsProfile();
}
/*!
* Returns true if this profile has been read from a disk file. Otherwise
* this object either does not transport an ICC profile, or the profile has
* been generated or assigned directly from a memory buffer.
*/
bool IsDiskProfile() const
{
return !m_path.IsEmpty();
}
/*!
* Returns true iff the ICC profile stored in this object is identical to the
* profile stored in \a other %ICCProfile object.
*
* If necessary, this function performs a byte-to-byte comparison between
* both ICC profile structures (when both have the same size in bytes).
*/
bool IsSameProfile( const ICCProfile& other ) const;
/*!
* Returns a reference to the immutable container that stores an ICC profile
* in this %ICCProfile object. The returned ByteArray is empty if this
* object does not transport an ICC color profile.
*/
const ByteArray& ProfileData() const
{
return m_data;
}
/*!
* Returns the length of the stored ICC profile structure in bytes. Returns
* zero if this %ICCProfile object doesn't store an ICC color profile.
*/
size_type ProfileSize() const;
/*!
* Returns the full file path of the stored ICC profile, if this object
* transports an ICC profile structure that has been loaded from a file, or
* an empty string otherwise.
*/
String FilePath() const
{
return m_path;
}
/*!
* Returns the localized profile description of the stored ICC profile.
*
* \param language Optional language code (ISO 639/2) of the requested
* profile description. The default value is "en" for
* English.
*
* \param country Optional country code (ISO 3166) of the requested
* profile description. The default value is "US" for
* United States.
*
* If this object does not transport an ICC profile, this routine returns an
* empty string. Otherwise this routine will always return a valid profile
* description, even if no localized version exists for the requested
* language and country. The returned description will be as close as
* possible to the requested localization.
*/
String Description( const char* language = "en", const char* country = "US" ) const;
/*!
* Returns the localized manufacturer information of the stored ICC profile.
*
* See Description( const char*, const char* ) const for detailed
* information on function parameters and behavior.
*/
String Manufacturer( const char* language = "en", const char* country = "US" ) const;
/*!
* Returns the localized device model information of the stored ICC profile.
*
* See Description( const char*, const char* ) const for detailed
* information on function parameters and behavior.
*/
String Model( const char* language = "en", const char* country = "US" ) const;
/*!
* Returns the localized copyright information of the stored ICC profile.
*
* See Description( const char*, const char* ) const for detailed
* information on function parameters and behavior.
*/
String Copyright( const char* language = "en", const char* country = "US" ) const;
/*!
* Retrieves localized description, manufacturer, device model and copyright
* information from the stored ICC profile.
*
* If this object does not transport an ICC profile, this routine clears the
* \a description, \a manufacturer, \a model and \a copyright strings. If a
* valid ICC profile is stored in this object, the passed strings will be
* assigned with the corresponding information, as close as possible to the
* requested localization. See Description( const char*, const char* ) const
* for detailed information on localization parameters.
*/
void GetInformation( String& description, String& manufacturer, String& model, String& copyright,
const char* language = "en", const char* country = "US" ) const;
/*!
* Returns the ICC profile class of the stored profile. See the
* ICCProfileClass namespace for supported profile classes.
*
* If this object doesn't transport an ICC profile, this function returns
* ICCProfileClass::Unknown.
*/
profile_class Class() const;
/*!
* Returns the ICC color space of the stored profile. See the ICCColorSpace
* namespace for supported color spaces.
*
* If this object doesn't transport an ICC profile, this function returns
* ICCColorSpace::Unknown.
*/
color_space ColorSpace() const;
/*!
* Returns true iff this object stores an RGB ICC profile.
*/
bool IsRGB() const
{
return ColorSpace() == ICCColorSpace::RGB;
}
/*!
* Returns true iff this object stores a grayscale ICC profile.
*/
bool IsGrayscale() const
{
return ColorSpace() == ICCColorSpace::Gray;
}
/*!
* Returns true iff this object stores an ICC profile that supports the
* specified \a intent in the specified transform \a direction. See the
* ICCRenderingIntent and ICCRenderingDirection namespaces, respectively,
* for supported rendering intents and directions.
*/
bool SupportsRenderingIntent( rendering_intent intent, rendering_direction direction ) const;
/*!
* Returns true iff this object stores an embedded ICC profile.
*
* An embedded ICC profile must have the <em>Embedded Profile</em> bit field
* (bit #0 of header byte #44) set.
*/
bool IsEmbedded() const;
/*!
* Sets or clears the <em>Embedded Profile</em> header bit field (bit #0 of
* header byte #44) of the stored ICC profile.
*
* \note If this %ICCProfile object is being used to embed an ICC profile in
* an image file, the <em>Embedded Profile</em> flag must be set before
* embedding.
*/
void SetEmbeddedFlag( bool on = true );
/*!
* Clears or sets the <em>Embedded Profile</em> header bit field (bit #0 of
* header byte #44) of the stored ICC profile.
*
* This is a convenience member function, equivalent to
* SetEmbeddedFlag( false )
*/
void ClearEmbeddedFlag()
{
SetEmbeddedFlag( false );
}
/*!
* Loads an ICC profile from a disk file at \a profilePath and stores it in
* this %ICCProfile object.
*
* If this object stores an ICC profile before calling this function, it is
* deallocated upon successful load of the specified ICC profile.
*
* If the specified file does not exist or is not readable, or if the file
* contains data that cannot be identified as a valid ICC profile, this
* function throws an Error exception.
*/
void Load( const String& profilePath );
/*!
* Forces this %ICCProfile object to store a copy of the ICC profile stored
* in the specified ByteArray container. Previously existing ICC profile
* data will be deallocated.
*
* If the specified container is empty, calling this function is equivalent
* to Clear(). If the container is not empty, it must store a valid ICC
* profile structure; otherwise this function will throw an Error exception.
*/
void Set( const ByteArray& profile );
/*!
* Forces this %ICCProfile object to store a copy of the raw ICC profile
* data at the specified location. Previously existing ICC profile data will
* be deallocated.
*
* The specified pointer must be the starting address of a valid ICC profile
* structure; otherwise this function will throw an Error exception.
*/
void Set( const void* rawData );
/*!
* Deallocates the stored ICC profile structure and all auxiliary data.
*
* If the profile has been opened before calling this function, any existing
* handle to it will not be closed or invalidated.
*/
void Clear()
{
m_data.Clear();
m_path.Clear();
}
/*!
* Opens the ICC profile stored in this %ICCProfile object. Returns a handle
* to the opened ICC profile.
*
* If this object does not transport a valid ICC profile structure, this
* function throws an Error exception.
*
* Color management transformations are defined through handles to open ICC
* profiles. The caller is responsible for closing ICC profile handles when
* they are no longer needed.
*/
handle Open() const
{
return Open( m_data );
}
/*!
* Exchanges two ICC profiles \a x1 and \a x2.
*/
friend void Swap( ICCProfile& x1, ICCProfile& x2 )
{
pcl::Swap( x1.m_data, x2.m_data );
pcl::Swap( x1.m_path, x2.m_path );
}
/*!
* Opens an ICC profile disk file at \a profilePath. Returns a handle to the
* opened ICC profile.
*
* If the specified file does not exist or is not readable, or if it does
* not contain a valid ICC profile structure, this function throws an Error
* exception.
*/
static handle Open( const String& profilePath );
/*!
* Opens an ICC profile from raw ICC profile data stored at the specified
* location. Returns a handle to the opened ICC profile.
*
* If the argument does not point to a valid ICC profile structure, this
* function throws an Error exception.
*/
static handle Open( const void* rawData );
/*!
* Opens an ICC profile stored in the specified ByteArray container \a icc.
* Returns a handle to the opened ICC profile.
*
* If the specified container is empty or does not contain a valid ICC
* profile structure, this function throws an Error exception.
*/
static handle Open( const ByteArray& icc )
{
return Open( icc.Begin() );
}
/*!
* Closes an open ICC profile handle.
*/
static void Close( handle h );
/*!
* Validates an ICC profile handle. Returns true iff the specified handle is
* a valid handle to an open ICC profile.
*/
static bool IsValidHandle( handle h );
/*!
* Validates an ICC profile structure stored in a file at \a profilePath.
* Returns true iff the specified file exists and contains a valid ICC
* profile.
*/
static bool IsValidFile( const String& profilePath );
/*!
* Validates an ICC profile from raw ICC profile data stored at the
* specified location. Returns true iff the argument points to a valid ICC
* profile structure.
*/
static bool IsValid( const void* rawdata );
/*!
* Validates an ICC profile structure stored in the specified ByteArray
* container \a icc. Returns true iff the container stores a valid ICC
* profile.
*/
static bool IsValid( const ByteArray& icc )
{
return IsValid( icc.Begin() );
}
/*!
* Returns the localized profile description of an open ICC profile.
*
* \param h Handle to an open ICC profile, from which the requested
* profile description will be obtained.
*
* \param language Optional language code (ISO 639/2) of the requested
* profile description. The default value is "en" for
* English.
*
* \param country Optional country code (ISO 3166) of the requested
* profile description. The default value is "US" for the
* United States.
*
* This routine will always return a valid profile description, even if no
* localized version is available for the requested language and country.
* The returned description will be as close as possible to the requested
* localization.
*/
static String Description( handle h, const char* language = "en", const char* country = "US" );
/*!
* Returns the localized manufacturer information of an open ICC profile.
*
* See Description( handle, const char*, const char* ) for detailed
* information on function parameters and behavior.
*/
static String Manufacturer( handle h, const char* language = "en", const char* country = "US" );
/*!
* Returns the localized device model information of an open ICC profile.
*
* See Description( handle, const char*, const char* ) for detailed
* information on function parameters and behavior.
*/
static String Model( handle h, const char* language = "en", const char* country = "US" );
/*!
* Returns the localized copyright information of an open ICC profile.
*
* See Description( handle, const char*, const char* ) for detailed
* information on function parameters and behavior.
*/
static String Copyright( handle h, const char* language = "en", const char* country = "US" );
/*!
* Returns the ICC profile class of an open profile. See the ICCProfileClass
* namespace for supported profile classes.
*/
static profile_class Class( handle h );
/*!
* Returns the ICC color space of an open profile. See the ICCColorSpace
* namespace for supported color spaces.
*/
static color_space ColorSpace( handle h );
/*!
* Returns true iff an open profile supports the specified \a intent in the
* specified transform \a direction. See the ICCRenderingIntent and
* ICCRenderingDirection namespaces, respectively, for supported rendering
* intents and directions.
*/
static bool SupportsRenderingIntent( handle h, rendering_intent intent, rendering_direction direction );
/*!
* Returns the list of profile directories.
*
* The profile directories contain the ICC profiles currently installed in
* the system. The specific directories provided by this function are
* platform-dependent.
*
* On X11 Linux and FreeBSD, there is no universally standardized color
* management system. By default, the returned list will include a single
* directory that can be one of the following:
*
* /usr/share/color/icc
* ~/.color/icc
*
* for system-wide or user-local profiles, respectively. If none of the
* above directories exists (and is readable) on the local filesystem, the
* routine will return a fallback directory within the installation
* directory tree of the PixInsight core application.
*
* On OS X, the returned list may contain one or more from the following
* directories:
*
* ~/Library/ColorSync/Profiles
* /Library/ColorSync/Profiles
* /Network/Library/ColorSync/Profiles
*
* Finally, on Windows this function returns the current COLOR directory,
* as reported by the GetColorDirectory() Win32 API function.
*/
static StringList ProfileDirectories();
/*!
* Gets a list of full paths for every ICC profile on a given directory.
*
* \param dirPath Optional path to a search directory. If no directory is
* specified, or if an empty string is passed, the whole
* list of system profile directories, as returned by the
* ProfileDirectories() member function, will be searched
* recursively.
*
* This routine performs a recursive directory search on the specified
* directory, or on each system profiles directory if no directory is
* specified. Profiles are quickly identified by opening them and validating
* their profile headers. The search is not limited to any particular file
* suffix such as ".icc" or ".icm".
*
* Returns a list of full paths to the ICC profile files found on the
* search directory.
*/
static StringList FindProfiles( const String& dirPath = String() );
/*!
* Finds the file path to an installed ICC profile, given its profile
* description.
*
* \param description Description of the profile to search for.
*
* \param exactMatch If true, this routine will search for a profile that
* matches the specified \a description exactly, including
* character case. If false, the routine will report any
* profile whose description contains the specified
* description performing case-insensitive comparisons.
* The default value is true, so profile descriptions must
* be matched exactly by default.
*
* This function searches the system color directories, as reported by the
* ProfileDirectories() member function, until it finds an ICC profile with
* the specified \a description. This routine performs a recursive directory
* search on each profiles directory.
*
* Returns the full path to the ICC profile, or an empty string if no
* profile was found matching the specified \a description.
*/
static String FindInstalledProfile( const String& description, bool exactMatch = true );
/*!
* Extracts a subset of profile paths and their descriptions from a
* previously retrieved list of full paths to ICC profiles.
*
* \param[out] selectedDescriptionsList The list of profile descriptions
* for selected profiles.
*
* \param[out] selectedPathsList The list of paths to selected profiles.
*
* \param pathList The input list of paths to ICC profiles.
*
* \param spaces A combination of ICC color spaces for selected ICC
* profiles.
*
* \param classes A combination of ICC device classes for selected ICC
* profiles.
*/
static void ExtractProfileList( StringList& selectedDescriptionsList,
StringList& selectedPathsList,
const StringList& pathList,
ICCColorSpaces spaces = ICCColorSpace::Any,
ICCProfileClasses classes = ICCProfileClass::Any );
// -------------------------------------------------------------------------
/*!
* \class pcl::ICCProfile::Info
* \brief A structure to hold descriptive data about ICC profiles.
* \ingroup color_management
*
* The %ICCProfile::Info structure is designed to be used with the
* ICCProfile::FindProfilesByColorSpace() utility function.
*/
struct Info
{
String description; //!< Description of an ICC profile
String path; //!< Full path to an ICC profile disk file
/*!
* Constructs an %ICCProfile::Info structure.
*/
Info( const String& a_description, const String& a_path = String() )
: description( a_description )
, path( a_path )
{
}
/*!
* Equality operator. Two %ICCProfile::Info objects are equal if their
* profile descriptions are equal.
*/
bool operator ==( const Info& x ) const
{
return description == x.description;
}
/*!
* Less than relational operator. %ICCProfile::Info objects are sorted by
* their profile descriptions
*/
bool operator <( const Info& x ) const
{
return description < x.description;
}
};
/*!
* Represents a sorted list of ICC profile information items.
*/
typedef SortedArray<Info> profile_list;
/*!
* Returns a sorted list of profile information items (full file paths and
* profile description strings) for the existing ICC profiles of the
* specified ICC profile color spaces.
*
* \param spaces A combination of ICC profile color spaces to search for.
*
* The search operation is restricted to the system color directories, as
* reported by the ProfileDirectories() member function. This routine
* performs a recursive directory search on each profiles directory.
*
* Duplicate profiles are not included in the output \a info list. If the
* same profile is present in two or more directories, or if the same
* profile is present on the same directory with different file names, only
* the first instance seen will be included. Profiles are compared by their
* profile descriptions.
*/
static profile_list FindProfilesByColorSpace( ICCColorSpaces spaces );
/*!
* \internal
*/
static void ThrowErrorWithCMSInfo( const String& message );
private:
ByteArray m_data; // ICC profile data
String m_path; // empty if this is an embedded or newly created profile
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_ICCProfile_h
// ----------------------------------------------------------------------------
// EOF pcl/ICCProfile.h - Released 2022-03-12T18:59:29Z
-691
View File
@@ -1,691 +0,0 @@
// ____ ______ __
// / __ \ / ____// /
// / /_/ // / / /
// / ____// /___ / /___ PixInsight Class Library
// /_/ \____//_____/ PCL 2.4.23
// ----------------------------------------------------------------------------
// pcl/ICCProfileTransformation.h - Released 2022-03-12T18:59:29Z
// ----------------------------------------------------------------------------
// This file is part of the PixInsight Class Library (PCL).
// PCL is a multiplatform C++ framework for development of PixInsight modules.
//
// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
//
// Redistribution and use in both source and binary forms, with or without
// modification, is permitted provided that the following conditions are met:
//
// 1. All redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. All redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
// of their contributors, may be used to endorse or promote products derived
// from this software without specific prior written permission. For written
// permission, please contact info@pixinsight.com.
//
// 4. All products derived from this software, in any form whatsoever, must
// reproduce the following acknowledgment in the end-user documentation
// and/or other materials provided with the product:
//
// "This product is based on software from the PixInsight project, developed
// by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
//
// Alternatively, if that is where third-party acknowledgments normally
// appear, this acknowledgment must be reproduced in the product itself.
//
// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ----------------------------------------------------------------------------
#ifndef __PCL_ICCProfileTransformation_h
#define __PCL_ICCProfileTransformation_h
/// \file pcl/ICCProfileTransformation.h
#include <pcl/Defs.h>
#include <pcl/Array.h>
#include <pcl/Color.h>
#include <pcl/ICCProfile.h>
#include <pcl/ImageTransformation.h>
#include <pcl/ParallelProcess.h>
// ----------------------------------------------------------------------------
#ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
namespace pi
{
class ImageWindow;
} // pi
#endif
namespace pcl
{
// ----------------------------------------------------------------------------
/*!
* \class ICCProfileTransformation
* \brief Conversion of pixel values between ICC profile color spaces
*
* %ICCProfileTransformation is a portable color transformation based on ICC
* color profiles. This class is a high-level interface to the color management
* functionality implemented in the PixInsight core application.
*
* %ICCProfileTransformation implements simple profile-to-profile color
* transformations, multiprofile transformations, and device proofing
* transformations with out-of-gamut checks.
*
* \ingroup color_management
* \sa ICCProfile, ImageTransformation
*/
class PCL_CLASS ICCProfileTransformation : public ImageTransformation, public ParallelProcess
{
public:
/*!
* Represents an ICC rendering intent.
*/
typedef ICCRenderingIntent::value_type rendering_intent;
/*!
* Represents an opaque handle to a server-side ICC transformation.
*/
typedef void* transformation_handle;
/*!
* Represents a list of handles to open ICC profiles.
*/
typedef Array<ICCProfile::handle> profile_list;
/*!
* Constructs an empty %ICCPRofileTransformation object.
*/
ICCProfileTransformation() = default;
/*!
* Move constructor.
*/
ICCProfileTransformation( ICCProfileTransformation&& x )
: ImageTransformation( x )
, ParallelProcess( x )
, m_transformation( x.m_transformation )
, m_profiles( std::move( x.m_profiles ) )
, m_intent( x.m_intent )
, m_proofingIntent( x.m_proofingIntent )
, m_blackPointCompensation( x.m_blackPointCompensation )
, m_forceFloatingPoint( x.m_forceFloatingPoint )
, m_highResolutionCLUT( x.m_highResolutionCLUT )
, m_lowResolutionCLUT( x.m_lowResolutionCLUT )
, m_proofingTransformation( x.m_proofingTransformation )
, m_gamutCheck( x.m_gamutCheck )
, m_srcRGB( x.m_srcRGB )
, m_dstRGB( x.m_dstRGB )
, m_floatingPoint( x.m_floatingPoint )
{
x.m_transformation = nullptr;
}
/*!
* Move assignment operator. Returns a reference to this object.
*/
ICCProfileTransformation& operator =( ICCProfileTransformation&& x )
{
(void)ImageTransformation::operator =( x );
(void)ParallelProcess::operator =( x );
m_transformation = x.m_transformation;
m_profiles = std::move( x.m_profiles );
m_intent = x.m_intent;
m_proofingIntent = x.m_proofingIntent;
m_blackPointCompensation = x.m_blackPointCompensation;
m_forceFloatingPoint = x.m_forceFloatingPoint;
m_highResolutionCLUT = x.m_highResolutionCLUT;
m_lowResolutionCLUT = x.m_lowResolutionCLUT;
m_proofingTransformation = x.m_proofingTransformation;
m_gamutCheck = x.m_gamutCheck;
m_srcRGB = x.m_srcRGB;
m_dstRGB = x.m_dstRGB;
m_floatingPoint = x.m_floatingPoint;
x.m_transformation = nullptr;
return *this;
}
/*!
* Copy constructor. This constructor is disabled because ICC color profile
* transformations are unique objects.
*/
ICCProfileTransformation( const ICCProfileTransformation& ) = delete;
/*!
* Copy assignment. This operator is disabled because ICC color profile
* transformations are unique objects.
*/
ICCProfileTransformation& operator =( const ICCProfileTransformation& ) = delete;
/*!
* Destroys an %ICCPRofileTransformation object.
*/
virtual ~ICCProfileTransformation()
{
Clear();
}
/*!
* Loads an ICC profile from a file at \a profilePath and adds it to this
* ICC profile transformation.
*/
void Add( const String& profilePath );
/*!
* Adds the specified ICC \a profile to this ICC profile transformation.
*/
void Add( const ICCProfile& profile );
/*!
* Adds an already open ICC profile \a profileHandle to this ICC profile
* transformation.
*/
void Add( const ICCProfile::handle profileHandle );
/*!
* Returns true iff this object represents a valid color space transformation
* based on ICC color profiles.
*
* For this member function to return true, the underlying low-level
* transformation should have been created, either implicitly by using
* this object to apply a color transformation, or explicitly by calling
* Create().
*/
bool IsValid() const
{
return m_transformation != nullptr;
}
/*!
* Returns a reference to the immutable list of ICC profiles in this ICC
* profile transformation.
*/
const profile_list& Profiles() const
{
return m_profiles;
}
/*!
* Returns the ICC rendering intent for this ICC profile transformation.
*/
rendering_intent RenderingIntent() const
{
return m_intent;
}
/*!
* Sets the ICC rendering intent for this ICC profile transformation.
*
* When no intent is set explicitly with this function, the default
* rendering intent is ICCRenderingIntent::Perceptual.
*/
void SetRenderingIntent( rendering_intent i )
{
CloseTransformation();
m_intent = i;
}
/*!
* Returns true iff this ICC profile transformation applies a <em>black point
* compensation</em> algorithm.
*/
bool UsingBlackPointCompensation() const
{
return m_blackPointCompensation;
}
/*!
* Enables or disables <em>black point compensation</em> for this ICC
* profile transformation.
*
* When not enabled explicitly with this function, no black point
* compensation is applied by default.
*/
void EnableBlackPointCompensation( bool enable = true )
{
CloseTransformation();
m_blackPointCompensation = enable;
}
/*!
* Disables or enables <em>black point compensation</em> for this ICC
* profile transformation.
*
* This is a convenience member function, equivalent to
* EnableBlackPointCompensation( !disable )
*/
void DisableBlackPointCompensation( bool disable = true )
{
EnableBlackPointCompensation( !disable );
}
/*!
* Returns true iff this ICC profile transformation forces the use of
* floating point operations for computation of transformed pixel samples of
* all numerical data types.
*
* When this option is disabled (which is its default state), 16-bit integer
* arithmetics will be used for 8-bit and 16-bit integer images. Floating
* point will always be used for the rest of images, irrespective of the
* state of this option, in order to preserve numerical accuracy.
*/
bool ForcesFloatingPointTransformation() const
{
return m_forceFloatingPoint;
}
/*!
* Enables or disables enforcement of floating point computations for this
* ICC profile transformation.
*/
void ForceFloatingPointTransformation( bool force = true )
{
CloseTransformation();
m_forceFloatingPoint = force;
}
/*!
* Disables or enables enforcement of floating point computations for this
* ICC profile transformation.
*
* This is a convenience member function, equivalent to
* ForceFloatingPointTransformation( !relax )
*/
void RelaxFloatingPointTransformation( bool relax = true )
{
ForceFloatingPointTransformation( !relax );
}
/*!
* Returns true iff this ICC profile transformation uses high-resolution
* color lookup tables (CLUTs) for precalculation of device link functions.
*
* Disabling high-resolution CLUTs may provide a (usually small) speed
* improvement.
*
* By default, %ICCProfileTransformation uses high-resolution CLUTs.
*/
bool UsingHighResolutionCLUT() const
{
return m_highResolutionCLUT;
}
/*!
* Enables or disables usage of high-resolution CLUT tables for this ICC
* profile transformation.
*/
void EnableHighResolutionCLUT( bool enable = true )
{
CloseTransformation();
if ( (m_highResolutionCLUT = enable) == true )
m_lowResolutionCLUT = false;
}
/*!
* Disables or enables usage of high-resolution CLUT tables for this ICC
* profile transformation.
*
* This is a convenience member function, equivalent to
* EnableHighResolutionCLUT( !disable )
*/
void DisableHighResolutionCLUT( bool disable = true )
{
EnableHighResolutionCLUT( !disable );
}
/*!
* Returns true iff this ICC profile transformation uses low-resolution color
* lookup tables (CLUTs) for precalculation of device link functions.
*
* Enabling low-resolution CLUTs may provide a (usually small) speed
* improvement.
*
* By default, %ICCProfileTransformation uses high-resolution CLUTs.
*/
bool UsingLowResolutionCLUT() const
{
return m_lowResolutionCLUT;
}
/*!
* Enables or disables usage of low-resolution color lookup tables (CLUTs)
* in this ICC color transformation.
*/
void EnableLowResolutionCLUT( bool enable = true )
{
CloseTransformation();
if ( (m_lowResolutionCLUT = enable) == true )
m_highResolutionCLUT = false;
}
/*!
* Disables or enables usage of low-resolution color lookup tables (CLUTs)
* in this ICC color transformation.
*
* This is a convenience member function, equivalent to
* EnableLowResolutionCLUT( !disable )
*/
void DisableLowResolutionCLUT( bool disable = true )
{
EnableLowResolutionCLUT( !disable );
}
/*!
* Returns true iff this object represents a device proofing transformation.
*/
bool IsProofingTransformation() const
{
return m_proofingTransformation;
}
/*!
* Forces the immediate creation (or re-creation) of the underlying
* low-level transformation.
*
* You normally shouldn't need to call this member function, since
* %ICCProfileTransformation automatically creates the necessary low-level
* transformations at the points they are required.
*/
void Create()
{
CreateTransformation( m_forceFloatingPoint );
}
/*!
* \internal
* Returns the low-level handle that this %ICCProfileTransformation object
* serves as a high-level interface to.
*
* This function is intended for private use of the PixInsight core
* application; you normally shouldn't need to call it.
*/
transformation_handle Handle() const
{
return m_transformation;
}
/*!
* Resets this %ICCProfileTransformation object to a default state.
*
* The list of ICC profiles is cleared and the underlying transformation and
* all associated data structures are destroyed.
*/
void Clear();
/*!
* Returns true iff the starting ICC profile in this transformation is a RGB
* profile.
*/
bool IsSourceRGBProfile() const
{
return m_srcRGB;
}
/*!
* Returns true iff the target (last) ICC profile in this transformation is a
* RGB profile.
*/
bool IsTargetRGBProfile() const
{
return m_dstRGB;
}
protected:
/*
* Opaque handle to the profile transformation.
*/
mutable transformation_handle m_transformation = nullptr;
/*
* The ICC profiles, rendering intents and operating parameters that define
* this color transformation.
*/
profile_list m_profiles;
rendering_intent m_intent = ICCRenderingIntent::Perceptual;
rendering_intent m_proofingIntent = ICCRenderingIntent::AbsoluteColorimetric;
bool m_blackPointCompensation = false;
bool m_forceFloatingPoint = false;
bool m_highResolutionCLUT = true;
bool m_lowResolutionCLUT = false;
bool m_proofingTransformation = false;
bool m_gamutCheck = false;
/*
* Flags indicating source and destination color spaces.
* ### NB: These refer to the color spaces of the source and target pixel
* buffers, *not* to the color spaces of the profiles involved in the
* transformation.
*/
mutable bool m_srcRGB = false;
mutable bool m_dstRGB = false;
/*
* Flag indicating whether the current transformation (if any) has been
* created forcing floating point arithmetics.
*/
mutable bool m_floatingPoint = false;
void AddAt( size_type, const String& );
void AddAt( size_type, const ICCProfile& );
void AddAt( size_type, const ICCProfile::handle );
void AddOrReplaceAt( size_type i, const ICCProfile::handle );
void CreateTransformation( bool ) const;
void CloseTransformation() const;
// Inherited from ImageTransformation
void Apply( pcl::Image& ) const override;
void Apply( pcl::DImage& ) const override;
void Apply( pcl::UInt8Image& ) const override;
void Apply( pcl::UInt16Image& ) const override;
void Apply( pcl::UInt32Image& ) const override;
};
// ----------------------------------------------------------------------------
/*!
* \class ICCProofingTransformation
* \brief A soft proofing ICC profile transformation
*
* %ICCProofingTransformation implements a <em>device proofing
* transformation</em>. This kind of color transformation allows previewing of
* the final results that would be obtained on a specific <em>proofing
* device</em> without actually performing any rendition on physical media.
*
* A device proofing transformation uses three ICC profiles: a <em>source
* profile</em>, a <em>proofing profile</em>, and a <em>target profile</em>. In
* a typical scenario, the proofing device is a printer and we want to proof it
* on a display monitor. In this common case we have:
*
* Source profile = The ICC profile describing the color space to which source
* pixel values are referred.
*
* Proofing profile = The ICC profile describing the device where the final
* result will be obtained (usually a printer).
*
* Target profile = The ICC profile describing the display device where we'll
* preview the result (usually a monitor).
*
* \ingroup color_management
* \sa ICCProfileTransformation, ICCProfile
*/
class PCL_CLASS ICCProofingTransformation : public ICCProfileTransformation
{
public:
/*!
* Constructs a default %ICCProofingTransformation object.
*/
ICCProofingTransformation()
{
m_proofingTransformation = true;
m_profiles.Add( static_cast<ICCProfile::handle>( nullptr ), 3 );
}
/*!
* Move constructor.
*/
ICCProofingTransformation( ICCProofingTransformation&& ) = default;
/*!
* Destroys an %ICCProofingTransformation object.
*/
virtual ~ICCProofingTransformation()
{
}
/*!
* Move assignment operator. Returns a reference to this object.
*/
ICCProofingTransformation& operator =( ICCProofingTransformation&& ) = default;
/*!
* Loads an ICC profile from a file at \a profilePath and selects it as the
* profile describing the source color space in this transformation.
*/
void SetSourceProfile( const String& profilePath );
/*!
* Selects the specified ICC \a profile as the profile describing the source
* color space in this transformation.
*/
void SetSourceProfile( const ICCProfile& profile );
/*!
* Selects an already open ICC profile \a profileHandle as the profile
* describing the source color space in this transformation.
*/
void SetSourceProfile( const ICCProfile::handle profileHandle );
/*!
* Loads an ICC profile from a file at \a profilePath and selects it as the
* profile describing the proofing device in this transformation.
*/
void SetProofingProfile( const String& profilePath );
/*!
* Selects the specified ICC \a profile as the profile describing the
* proofing device in this transformation.
*/
void SetProofingProfile( const ICCProfile& profile );
/*!
* Selects an already open ICC profile \a profileHandle as the profile
* describing the proofing device in this transformation.
*/
void SetProofingProfile( const ICCProfile::handle profileHandle );
/*!
* Loads an ICC profile from a file at \a profilePath and selects it as the
* profile describing the target (output) color space in this
* transformation.
*/
void SetTargetProfile( const String& profilePath );
/*!
* Selects the specified ICC \a profile as the profile describing the target
* (output) color space in this transformation.
*/
void SetTargetProfile( const ICCProfile& profile );
/*!
* Selects an already open ICC profile \a profileHandle as the profile
* describing the target (output) color space in this transformation.
*/
void SetTargetProfile( const ICCProfile::handle profileHandle );
/*!
* Returns the proofing rendering intent for this ICC proofing
* transformation.
*/
rendering_intent ProofingIntent() const
{
return m_intent;
}
/*!
* Sets the proofing rendering intent for this ICC proofing transformation.
*
* The default proofing intent is ICCRenderingIntent::AbsoluteColorimetric.
*/
void SetProofingIntent( rendering_intent i )
{
CloseTransformation();
m_proofingIntent = i;
}
/*!
* Returns true iff <em>gamut checking</em> has been enabled for this color
* transformation. When gamut check is enabled, out-of-gamut colors in the
* final rendition are automatically replaced by the current <em>gamut
* warning color</em> (see the SetGamutWarningColor() member function).
*/
bool IsGamutCheckEnabled() const
{
return m_gamutCheck;
}
/*!
* Enables or disables <em>gamut check</em> for this color transformation.
*/
void EnableGamutCheck( bool enable = true )
{
CloseTransformation();
m_gamutCheck = enable;
}
/*!
* Disables or enables <em>gamut check</em> for this color transformation.
*/
void DisableGamutCheck( bool disable = true )
{
EnableGamutCheck( !disable );
}
/*!
* Returns the current <em>gamut warning color</em> used to represent
* out-of-gamut pixel values in final proofing renditions. The returned
* value is a 32-bit RGBA pixel value.
*/
static RGBA GamutWarningColor();
/*!
* Specifies the special RGB color used to represent out-of-gamut pixel
* values in final proofing renditions. Only used for proofing
* transformations with <em>gamut check</em> enabled.
*
* \param color Gamut warning color encoded as a 32-bit RGBA pixel value.
*
* Note that since this is a static member function, the current gamut
* warning color is a global setting that affects all proofing
* transformations performed by the calling module.
*/
static void SetGamutWarningColor( RGBA color );
};
// ----------------------------------------------------------------------------
} // pcl
#endif // __PCL_ICCProfileTransformation_h
// ----------------------------------------------------------------------------
// EOF pcl/ICCProfileTransformation.h - Released 2022-03-12T18:59:29Z

Some files were not shown because too many files have changed in this diff Show More