@loveluthien/carta-frontend 6.0.0-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +34 -0
  2. package/.github/pull_request_template.md +23 -0
  3. package/.github/workflows/continuous_integration.yml +139 -0
  4. package/.github/workflows/deploy.yml +30 -0
  5. package/.husky/pre-commit +16 -0
  6. package/.husky/pre-push +42 -0
  7. package/.prettierignore +1 -0
  8. package/.prettierrc.json +18 -0
  9. package/CHANGELOG.md +363 -0
  10. package/COPYING.md +636 -0
  11. package/README.md +112 -0
  12. package/babel.config.json +10 -0
  13. package/build/ast_wrapper.wasm +0 -0
  14. package/build/carta_computation.wasm +0 -0
  15. package/build/carta_icon_128px.png +0 -0
  16. package/build/carta_logo.png +0 -0
  17. package/build/gsl_wrapper.wasm +0 -0
  18. package/build/index.html +147 -0
  19. package/build/manifest.json +15 -0
  20. package/build/robots.txt +3 -0
  21. package/build/static/css/546.aa44a897.css +1 -0
  22. package/build/static/css/async/359.4d8f6ff7.css +1 -0
  23. package/build/static/css/async/403.ea9edfac.css +1 -0
  24. package/build/static/css/async/462.8bde08e0.css +1 -0
  25. package/build/static/css/index.c1f77b92.css +1 -0
  26. package/build/static/font/blueprint-icons-16.5fb1af27.woff2 +0 -0
  27. package/build/static/font/blueprint-icons-16.79f603d1.woff +0 -0
  28. package/build/static/font/blueprint-icons-16.83d51978.eot +0 -0
  29. package/build/static/font/blueprint-icons-16.af0c342f.ttf +0 -0
  30. package/build/static/font/blueprint-icons-20.83fddc09.ttf +0 -0
  31. package/build/static/font/blueprint-icons-20.9a51bc58.woff +0 -0
  32. package/build/static/font/blueprint-icons-20.d61315fe.eot +0 -0
  33. package/build/static/font/blueprint-icons-20.ebf16e9a.woff2 +0 -0
  34. package/build/static/image/allmaps.03f2ba92.png +0 -0
  35. package/build/static/image/gamma.6fca425b.png +0 -0
  36. package/build/static/image/linear.c7941b64.png +0 -0
  37. package/build/static/image/log.7fce6aee.png +0 -0
  38. package/build/static/image/power.5dac9727.png +0 -0
  39. package/build/static/image/sqrt.0ec2b3f1.png +0 -0
  40. package/build/static/image/squared.798b23aa.png +0 -0
  41. package/build/static/js/546.b5841ade.js +489 -0
  42. package/build/static/js/546.b5841ade.js.LICENSE.txt +925 -0
  43. package/build/static/js/async/359.97257512.js +1 -0
  44. package/build/static/js/async/403.b00f768c.js +1 -0
  45. package/build/static/js/async/462.92c07a07.js +1 -0
  46. package/build/static/js/async/905.70044ee8.js +1 -0
  47. package/build/static/js/async/907.dc17f1d2.js +1 -0
  48. package/build/static/js/async/blueprint-icons-16px-paths.e17db832.js +1 -0
  49. package/build/static/js/async/blueprint-icons-20px-paths.6ad43f5f.js +1 -0
  50. package/build/static/js/async/blueprint-icons-all-paths-loader.61cc0f7b.js +1 -0
  51. package/build/static/js/async/blueprint-icons-all-paths.0c699441.js +1 -0
  52. package/build/static/js/async/blueprint-icons-split-paths-by-size-loader.5cff79f5.js +1 -0
  53. package/build/static/js/index.8fc34b4d.js +1344 -0
  54. package/build/static/js/index.9a30d560.worker.js +1 -0
  55. package/build/static/js/zfp_wrapper.wasm +0 -0
  56. package/build/static/svg/blueprint-icons-16.130888ef.svg +2097 -0
  57. package/build/static/svg/blueprint-icons-20.c8456d56.svg +2097 -0
  58. package/build/zfp_wrapper.wasm +0 -0
  59. package/declarations.d.ts +18 -0
  60. package/docs_website/.prettierignore +1 -0
  61. package/docs_website/api/api.md +13 -0
  62. package/docs_website/babel.config.js +3 -0
  63. package/docs_website/docs/assets/enable-code-snippets.png +0 -0
  64. package/docs_website/docs/code-snippet-tutorial/_category_.json +8 -0
  65. package/docs_website/docs/code-snippet-tutorial/basics.md +97 -0
  66. package/docs_website/docs/code-snippet-tutorial/image-blending.mdx +57 -0
  67. package/docs_website/docs/code-snippet-tutorial/image-fitting.mdx +44 -0
  68. package/docs_website/docs/code-snippet-tutorial/image-properties.mdx +84 -0
  69. package/docs_website/docs/code-snippet-tutorial/moment-images.mdx +31 -0
  70. package/docs_website/docs/code-snippet-tutorial/pv-images.mdx +28 -0
  71. package/docs_website/docs/code-snippet-tutorial/quick-start.mdx +82 -0
  72. package/docs_website/docs/code-snippet-tutorial/regions.mdx +49 -0
  73. package/docs_website/docs/contributing/_category_.json +7 -0
  74. package/docs_website/docs/contributing/developer-tips.md +61 -0
  75. package/docs_website/docs/contributing/documentation-guidelines.md +87 -0
  76. package/docs_website/docs/contributing/github-workflow.md +146 -0
  77. package/docs_website/docs/contributing/release-guidelines.md +73 -0
  78. package/docs_website/docs/contributing/unit-test-guidelines.md +79 -0
  79. package/docs_website/docs/documents.mdx +15 -0
  80. package/docs_website/docusaurus.config.js +167 -0
  81. package/docs_website/package-lock.json +16769 -0
  82. package/docs_website/package.json +121 -0
  83. package/docs_website/patches/@docusaurus+core+3.9.2.patch +20 -0
  84. package/docs_website/sidebars.js +33 -0
  85. package/docs_website/static/.nojekyll +0 -0
  86. package/docs_website/static/img/carta_icon_128px.png +0 -0
  87. package/docs_website/versioned_docs/version-4.1.0/api-packages.json +1 -0
  88. package/docs_website/versioned_docs/version-4.1.0/api-typedoc.json +214112 -0
  89. package/docs_website/versioned_docs/version-4.1.0/assets/enable-code-snippets.png +0 -0
  90. package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/_category_.json +8 -0
  91. package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/basics.md +97 -0
  92. package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/image-fitting.mdx +42 -0
  93. package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/image-properties.mdx +86 -0
  94. package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/moment-images.mdx +31 -0
  95. package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/pv-images.mdx +28 -0
  96. package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/quick-start.mdx +82 -0
  97. package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/regions.mdx +49 -0
  98. package/docs_website/versioned_docs/version-4.1.0/contributing/_category_.json +7 -0
  99. package/docs_website/versioned_docs/version-4.1.0/contributing/developer-tips.md +36 -0
  100. package/docs_website/versioned_docs/version-4.1.0/contributing/documentation-guidelines.md +87 -0
  101. package/docs_website/versioned_docs/version-4.1.0/contributing/github-workflow.md +141 -0
  102. package/docs_website/versioned_docs/version-4.1.0/contributing/release-guidelines.md +73 -0
  103. package/docs_website/versioned_docs/version-4.1.0/contributing/unit-test-guidelines.md +79 -0
  104. package/docs_website/versioned_docs/version-4.1.0/documents.mdx +15 -0
  105. package/docs_website/versioned_docs/version-5.0.0/api-packages.json +1 -0
  106. package/docs_website/versioned_docs/version-5.0.0/api-typedoc.json +315266 -0
  107. package/docs_website/versioned_docs/version-5.0.0/assets/enable-code-snippets.png +0 -0
  108. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/_category_.json +8 -0
  109. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/basics.md +97 -0
  110. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/image-blending.mdx +57 -0
  111. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/image-fitting.mdx +44 -0
  112. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/image-properties.mdx +86 -0
  113. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/moment-images.mdx +31 -0
  114. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/pv-images.mdx +28 -0
  115. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/quick-start.mdx +82 -0
  116. package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/regions.mdx +49 -0
  117. package/docs_website/versioned_docs/version-5.0.0/contributing/_category_.json +7 -0
  118. package/docs_website/versioned_docs/version-5.0.0/contributing/developer-tips.md +36 -0
  119. package/docs_website/versioned_docs/version-5.0.0/contributing/documentation-guidelines.md +87 -0
  120. package/docs_website/versioned_docs/version-5.0.0/contributing/github-workflow.md +141 -0
  121. package/docs_website/versioned_docs/version-5.0.0/contributing/release-guidelines.md +73 -0
  122. package/docs_website/versioned_docs/version-5.0.0/contributing/unit-test-guidelines.md +79 -0
  123. package/docs_website/versioned_docs/version-5.0.0/documents.mdx +15 -0
  124. package/docs_website/versioned_sidebars/version-4.1.0-sidebars.json +8 -0
  125. package/docs_website/versioned_sidebars/version-5.0.0-sidebars.json +8 -0
  126. package/docs_website/versions.json +4 -0
  127. package/eslint.config.mjs +86 -0
  128. package/jest.config.js +101 -0
  129. package/package.json +186 -0
  130. package/patches/golden-layout+1.5.9.patch +24 -0
  131. package/patches/react-split-pane+0.1.92.patch +20 -0
  132. package/rsbuild.config.ts +75 -0
  133. package/schemas/.github/workflows/AddToCartaVisProject.yml +23 -0
  134. package/schemas/.prettierrc.json +18 -0
  135. package/schemas/CMakeLists.txt +15 -0
  136. package/schemas/README.md +1 -0
  137. package/schemas/_config.yml +7 -0
  138. package/schemas/controller_config_schema_1.json +343 -0
  139. package/schemas/controller_config_schema_2.json +685 -0
  140. package/schemas/layout_schema_2.json +440 -0
  141. package/schemas/preference_backend_schema_1.json +81 -0
  142. package/schemas/preference_backend_schema_2.json +118 -0
  143. package/schemas/preference_schema_1.json +410 -0
  144. package/schemas/preferences_schema_2.json +421 -0
  145. package/schemas/schemacompiler.c +200 -0
  146. package/schemas/snippet_schema_1.json +45 -0
  147. package/schemas/workspace_schema_1.json +573 -0
  148. package/scripts/make_colormaps.py +161 -0
Binary file
@@ -0,0 +1,18 @@
1
+ declare module "*.png" {
2
+ const value: any;
3
+ export = value;
4
+ }
5
+ declare module "*.svg" {
6
+ const value: any;
7
+ export = value;
8
+ }
9
+ declare module "*.jpg" {
10
+ const value: any;
11
+ export = value;
12
+ }
13
+
14
+ declare module '*.glsl';
15
+ declare module '*.frag';
16
+ declare module '*.vert';
17
+
18
+ declare module '!worker-loader*';
@@ -0,0 +1 @@
1
+ versioned_docs/**/api-*.json
@@ -0,0 +1,13 @@
1
+ ## Table of Contents
2
+
3
+ - <ApiLink path="/.-components"><h4>Components</h4></ApiLink>
4
+
5
+ - <ApiLink path="/.-components/Dialogs"><h5>Components - Dialogs</h5></ApiLink>
6
+ - <ApiLink path="/.-components/Shared"><h5>Components - Shared</h5></ApiLink>
7
+
8
+ - <ApiLink path="/.-enums"><h4>Enums</h4></ApiLink>
9
+ - <ApiLink path="/.-models"><h4>Models</h4></ApiLink>
10
+ - <ApiLink path="/.-services"><h4>Services</h4></ApiLink>
11
+ - <ApiLink path="/.-stores"><h4>Stores</h4></ApiLink>
12
+ - <ApiLink path="/.-utilities"><h4>Utilities</h4></ApiLink>
13
+ - <ApiLink path="/changelog"><h4>Changelog</h4></ApiLink>
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ presets: [require.resolve("@docusaurus/core/lib/babel/preset")]
3
+ };
@@ -0,0 +1,8 @@
1
+ {
2
+ "label": "Code snippet tutorial",
3
+ "position": 2,
4
+ "link": {
5
+ "type": "generated-index",
6
+ "description": "Tutorials for the code snippet feature in CARTA frontend."
7
+ }
8
+ }
@@ -0,0 +1,97 @@
1
+ ---
2
+ sidebar_position: 2
3
+ ---
4
+
5
+ # Basics
6
+
7
+ Code snippets are regular ES6-based JavaScript (JS) code blocks.
8
+
9
+ Lines starting with "//" are treated as comments. You can also comment in multiple lines using C-style comments.
10
+
11
+ ```javascript
12
+ // Lines starting with "//" are treated as comments.
13
+ /* you can also comment in
14
+ * multiple lines using C-style comments
15
+ */
16
+ ```
17
+
18
+ To log to the development console, use `console.log`.
19
+
20
+ ```javascript
21
+ console.log("hello world");
22
+ ```
23
+
24
+ Variables can be defined using `let` (mutable) or `const` (immutable).
25
+
26
+ ```javascript
27
+ let x = 1;
28
+ const y = "hello world";
29
+ x += 15;
30
+ ```
31
+
32
+ ## Functions
33
+
34
+ Functions can be defined in a number of ways.
35
+
36
+ ```javascript
37
+ function squared(x) {
38
+ return x * x;
39
+ }
40
+
41
+ // This is an arrow function
42
+ const cubed = x => x * x * x;
43
+
44
+ // This is an arrow function with a block of codes
45
+ const sqrt = x => {
46
+ // You can use builtin JS library functions
47
+ return Math.sqrt(x);
48
+ };
49
+ ```
50
+
51
+ Functions can also be asynchronous. Any functions that wait for user input or interact with the backend will be asynchronous.
52
+
53
+ ```javascript
54
+ function delay(time) {
55
+ return new Promise((resolve, reject) => {
56
+ if (time < 0) {
57
+ reject("Invalid delay duration");
58
+ } else {
59
+ setTimeout(resolve, time);
60
+ }
61
+ });
62
+ }
63
+ ```
64
+
65
+ You can `await` asynchronous functions within another async function, or at the top level.
66
+
67
+ ```javascript
68
+ async function pauseForOneSecond() {
69
+ await delay(1000);
70
+ return true;
71
+ }
72
+ ```
73
+
74
+ Awaiting is necessary to ensure that return values can be used correctly. Compare the following outputs:
75
+
76
+ ```javascript
77
+ console.log("Awaiting properly:");
78
+ const resultWithAwait = await pauseForOneSecond();
79
+ console.log(resultWithAwait);
80
+ console.log();
81
+
82
+ console.log("No await:");
83
+ const resultWithoutAwait = pauseForOneSecond();
84
+ console.log(resultWithoutAwait);
85
+ console.log();
86
+ ```
87
+
88
+ Asynchronous functions can also be used with promise syntax.
89
+
90
+ ```javascript
91
+ delay(100).then(() => console.log("Looks promising"));
92
+ delay(-100).catch(err => console.log(err));
93
+ ```
94
+
95
+ Note that the response to the first "delay" call is printed after the second one, because execution is non-blocking.
96
+
97
+ For more usages of ES6-based JavaScript, please refer to the features of the language.
@@ -0,0 +1,57 @@
1
+ ---
2
+ sidebar_position: 8
3
+ ---
4
+
5
+ # Image blending
6
+
7
+ Actions related to color blended images.
8
+
9
+ ## Creating color blended images
10
+
11
+ <ApiLink path="/.-stores/class/ImageViewConfigStore/#createColorBlending">`createColorBlending`</ApiLink> creates a color blended image with a base layer from the spatial reference image and at most nine other layers from the spatially matched
12
+ images.
13
+
14
+ ```javascript
15
+ // Open three images
16
+ const file1 = await app.openFile("image_r.fits");
17
+ const file2 = await app.appendFile("image_g.fits");
18
+ const file3 = await app.appendFile("image_b.fits");
19
+
20
+ // Match images
21
+ file2.setSpatialReference(file1);
22
+ file3.setSpatialReference(file1);
23
+
24
+ // Create a color blended image
25
+ const colorBlendingStore = app.imageViewConfigStore.createColorBlending();
26
+ console.log(colorBlendingStore.frames.length); // 3
27
+ ```
28
+
29
+ <ApiLink path="/.-stores/class/ImageViewConfigStore/#removeColorBlending">`removeColorBlending`</ApiLink> closes a color blended image.
30
+
31
+ ```javascript
32
+ app.imageViewConfigStore.removeColorBlending(colorBlendingStore);
33
+ ```
34
+
35
+ ## Color blending configuration
36
+
37
+ The configuration of the color blended image is accessible via <ApiLink path="/.-stores/class/ColorBlendingStore">`ColorBlendingStore`</ApiLink>.
38
+
39
+ ```javascript
40
+ // Add a new layer
41
+ const file4 = await app.appendFile(path, "new_image.fits");
42
+ file4.setSpatialReference(file1);
43
+ colorBlendingStore.addSelectedFrame(file4);
44
+
45
+ // Delete a layer
46
+ colorBlendingStore.deleteSelectedFrame(2); // The fourth layer (the third selected layer)
47
+
48
+ // Set alpha
49
+ colorBlendingStore.setAlpha(0, 0.5); // The base layer
50
+ colorBlendingStore.setAlpha(1, 0.7); // The second layer
51
+ ```
52
+
53
+ Render configuration of each layer can be modified using <ApiLink path="/.-stores/class/RenderConfigStore">`renderConfig`</ApiLink>. The configuration is synchronized with the loaded image.
54
+
55
+ ```javascript
56
+ colorBlendingStore.frames[0].renderConfig.setColorMap("gray");
57
+ ```
@@ -0,0 +1,44 @@
1
+ ---
2
+ sidebar_position: 7
3
+ ---
4
+
5
+ # Image fitting
6
+
7
+ The process of fitting images with multiple Gaussians can be done using code snippets.
8
+
9
+ The configuration for the fitting is accessible via <ApiLink path="/.-stores/class/ImageFittingStore">`ImageFittingStore`</ApiLink>. Example code:
10
+
11
+ ```javascript
12
+ // Open an image
13
+ const file = await app.openFile("[filename]");
14
+
15
+ // Display the fitting widget
16
+ app.dialogStore.showDialog("fitting-dialog");
17
+
18
+ // Set the number of Gaussian components
19
+ app.imageFittingStore.setComponents(2);
20
+
21
+ // Option 1: Fit the image with auto generated initial values
22
+ app.imageFittingStore.fitImage();
23
+
24
+ // Option 2: Fit the image without auto generated initial values
25
+ app.imageFittingStore.setIsAutoInitVal(false);
26
+
27
+ const component1 = app.imageFittingStore.components[0];
28
+ component1.setCenterX(128);
29
+ component1.setCenterY(129);
30
+ component1.setAmplitude(0.01);
31
+ component1.setFwhmX(10);
32
+ component1.setFwhmY(6);
33
+ component1.setPa(36);
34
+
35
+ const component2 = app.imageFittingStore.components[1];
36
+ component2.setCenterX(135);
37
+ component2.setCenterY(135);
38
+ component2.setAmplitude(0.01);
39
+ component2.setFwhmX(4);
40
+ component2.setFwhmY(9);
41
+ component2.setPa(40);
42
+
43
+ app.imageFittingStore.fitImage();
44
+ ```
@@ -0,0 +1,84 @@
1
+ ---
2
+ sidebar_position: 3
3
+ ---
4
+
5
+ # Image properties
6
+
7
+ Actions for modifying various properties of the image. In the following examples, we assume that an image is loaded as
8
+
9
+ ```javascript
10
+ const file = await app.openFile("my_image.fits");
11
+ ```
12
+
13
+ ## Changing field of view
14
+
15
+ The field of view can be adjusted using various functions within <ApiLink path="/.-stores/class/FrameStore">`FrameStore`</ApiLink>.
16
+
17
+ <ApiLink path="/.-stores/class/FrameStore/#setCenter">`setCenter`</ApiLink> and <ApiLink path="/.-stores/class/FrameStore/#setCenterWcs">`setCenterWcs`</ApiLink> set the center of the image.
18
+
19
+ ```javascript
20
+ // image coordinate
21
+ file.setCenter([x position], [y position]);
22
+
23
+ // world coordinate
24
+ file.setCenterWcs("[x position, ex: 0:00:00.0615838925]", "[y position, ex: 29:59:59.1999990820]");
25
+ ```
26
+
27
+ <ApiLink path="/.-stores/class/FrameStore/#fitZoom">`fitZoom`</ApiLink> zooms the image to fit the widget size.
28
+
29
+ ```javascript
30
+ file.fitZoom();
31
+ ```
32
+
33
+ <ApiLink path="/.-stores/class/FrameStore/#zoomToSizeX">`zoomToSize...`</ApiLink> functions zoom the image to a specific scale.
34
+
35
+ ```javascript
36
+ // image coordinate
37
+ file.zoomToSizeX([size in x direction]);
38
+ file.zoomToSizeY([size in y direction]);
39
+
40
+ // world coordinate
41
+ file.zoomToSizeXWcs('[size in x direction, ex: 2.56"]');
42
+ file.zoomToSizeYWcs('[size in y direction, ex: 2.56"]');
43
+ ```
44
+
45
+ ## Changing the channel and Stokes
46
+
47
+ <ApiLink path="/.-stores/class/FrameStore/#setChannel">`setChannel`</ApiLink> changes the channel of the image.
48
+
49
+ ```javascript
50
+ file.setChannel([channel]);
51
+ ```
52
+
53
+ <ApiLink path="/.-stores/class/FrameStore/#setStokes">`setStokes`</ApiLink> and <ApiLink path="/.-stores/class/FrameStore/#setStokesByIndex">`setStokesByIndex`</ApiLink> change the stokes of the image using the polarization enum or the index.
54
+
55
+ ```javascript
56
+ file.setStokes(2); // Stokes Q
57
+ file.setStokesByIndex(2); // The third polarization shown in the animator widget
58
+ ```
59
+
60
+ ## Changing render configuration
61
+
62
+ Render configuration can be modified using <ApiLink path="/.-stores/class/RenderConfigStore">`renderConfig`</ApiLink> within <ApiLink path="/.-stores/class/FrameStore">`FrameStore`</ApiLink>.
63
+
64
+ <ApiLink path="/.-stores/class/RenderConfigStore/#setCustomScale">`setCustomScale`</ApiLink> and <ApiLink path="/.-stores/class/RenderConfigStore/#setPercentileRank">`setPercentileRank`</ApiLink> change the rendering range.
65
+
66
+ ```javascript
67
+ file.renderConfig.setCustomScale([clip min], [clip max]);
68
+ file.renderConfig.setPercentileRank(90); // Change to 90%
69
+ ```
70
+
71
+ <ApiLink path="/.-stores/class/RenderConfigStore/#setScaling">`setScaling`</ApiLink> changes the scaling functions using the FrameScaling enum.
72
+
73
+ ```javascript
74
+ file.renderConfig.setScaling(1); // Log
75
+ ```
76
+
77
+ <ApiLink path="/.-stores/class/RenderConfigStore/#setColorMap">`setColorMap`</ApiLink> changes the color map using options in <ApiLink path="/.-stores/class/RenderConfigStore/#COLOR_MAPS_ALL">`COLOR_MAPS_ALL`</ApiLink> list, and <ApiLink path="/.-stores/class/RenderConfigStore/#setInverted">
78
+ `setInverted`
79
+ </ApiLink> inverts the color map.
80
+
81
+ ```javascript
82
+ file.renderConfig.setColorMap("gray");
83
+ file.renderConfig.setInverted(true);
84
+ ```
@@ -0,0 +1,31 @@
1
+ ---
2
+ sidebar_position: 5
3
+ ---
4
+
5
+ # Moment images
6
+
7
+ The process of generating moment images can be done using code snippets.
8
+
9
+ The configuration for the generator is accessible via <ApiLink path="/.-stores/class/SpectralProfileWidgetStore">`SpectralProfileWidgetStore`</ApiLink>. Available moment types (as enum) can be found [here](https://carta-protobuf.readthedocs.io/en/latest/enums.html#moment). Example code:
10
+
11
+ ```javascript
12
+ // Open an image
13
+ const file = await app.openFile("[filename]");
14
+
15
+ // Create a spectral profile settings widget
16
+ app.widgetsStore.createFloatingSpectralProfilerWidget();
17
+ app.widgetsStore.createFloatingSettingsWidget("", "spectral-profiler-0", "spectral-profiler");
18
+
19
+ // Get the SpectralProfileWidgetStore object
20
+ const spectralProfileWidget = app.widgetsStore.spectralProfileWidgets.get("spectral-profiler-0");
21
+
22
+ // Navigate to the moments tab
23
+ spectralProfileWidget.setSettingsTabId(3);
24
+
25
+ // Modify the configuration using SpectralProfileWidgetStore
26
+ spectralProfileWidget.clearSelectedMoments(); // remove default: integrated value of the spectrum
27
+ spectralProfileWidget.selectMoment(0); // mean value of the spectrum
28
+
29
+ // Generate a moment image
30
+ spectralProfileWidget.requestMoment();
31
+ ```
@@ -0,0 +1,28 @@
1
+ ---
2
+ sidebar_position: 6
3
+ ---
4
+
5
+ # PV images
6
+
7
+ The process of generating PV images can be done using code snippets.
8
+
9
+ The configuration for the generator is accessible via <ApiLink path="/.-stores/class/PvGeneratorWidgetStore">`PvGeneratorWidgetStore`</ApiLink>. Example code:
10
+
11
+ ```javascript
12
+ // Open an image
13
+ const file = await app.openFile("[filename]");
14
+
15
+ // Create a line region
16
+ const region = await file.regionSet.addRegionAsync(1, [{x: [start x], y: [start y]}, {x: [end x], y: [end y]}]);
17
+
18
+ // Create a pv generator widget
19
+ app.widgetsStore.createFloatingPvGeneratorWidget();
20
+
21
+ // Get the PvGeneratorWidgetStore object
22
+ const pvGeneratorWidget = app.widgetsStore.pvGeneratorWidgets.get("pv-generator-0");
23
+
24
+ // Generate a pv image
25
+ pvGeneratorWidget.setFileId(file.frameInfo.fileId);
26
+ pvGeneratorWidget.setRegionId(file.frameInfo.fileId, region.regionId);
27
+ pvGeneratorWidget.requestPV();
28
+ ```
@@ -0,0 +1,82 @@
1
+ ---
2
+ sidebar_position: 1
3
+ ---
4
+
5
+ # Quick start
6
+
7
+ ## Enabling code snippets
8
+
9
+ The code snippet feature can be enabled via the preferences dialog:
10
+
11
+ <img src={require("../assets/enable-code-snippets.png").default} alt="Enable code snippets" width="500" />
12
+
13
+ Once the code snippet feature is enabled, the "Snippets" option appears in the menu. This allows you to create and run code snippets, providing additional functionality to CARTA.
14
+
15
+ ## Loading images
16
+
17
+ CARTA functions and objects can be accessed via the top-level <ApiLink path="/.-stores/class/AppStore">`app`</ApiLink> object (or the <ApiLink path="/.-stores/class/AppStore">`carta`</ApiLink> alias). In the following example, we display the welcome splash screen for 1000 ms and then close it.
18
+
19
+ ```javascript
20
+ carta.showSplashScreen();
21
+ await carta.delay(1000);
22
+ app.hideSplashScreen();
23
+ ```
24
+
25
+ Images loaded in the frontend are referred as and registered in the <ApiLink path="/.-stores/class/AppStore/#frames">`frames`</ApiLink> array which contains each frame (i.e., image) as a <ApiLink path="/.-stores/class/FrameStore">`FrameStore`</ApiLink> object. The currently active frame is accessible with <ApiLink path="/.-stores/class/AppStore/#activeFrame">`activeFrame`</ApiLink>. In the following example, we firstly list the frames array, then list the 0th frame, and finally list the current active frame in the console.
26
+
27
+ ```javascript
28
+ console.log(app.frames);
29
+ console.log(app.frames[0]);
30
+ console.log(app.activeFrame);
31
+ ```
32
+
33
+ <ApiLink path="/.-stores/class/AppStore/#openFile">`openFile`</ApiLink> takes up to three arguments: directory, filename and HDU. If no HDU is provided, the first HDU ("0") is adopted. The directory and filename can also be combined into a single
34
+ argument. <ApiLink path="/.-stores/class/AppStore/#openFile">`openFile`</ApiLink> must be called with `await`, as it is an asynchronous function that requires communicating with the backend. In the following example, in the end we will see that
35
+ only the last image is loaded as each <ApiLink path="/.-stores/class/AppStore/#openFile">`openFile`</ApiLink> will close all loaded image first before loading the target image.
36
+
37
+ ```javascript
38
+ await app.openFile("test_directory", "testfile.fits", "0");
39
+ await app.openFile("test_directory", "testfile.fits");
40
+ await app.openFile("test_directory/testfile.fits");
41
+ ```
42
+
43
+ Additional images can be appended using <ApiLink path="/.-stores/class/AppStore/#appendFile">`appendFile`</ApiLink>. The arguments are the same as <ApiLink path="/.-stores/class/AppStore/#openFile">`openFile`</ApiLink>. In the following example, in the end there will be three images loaded.
44
+
45
+ ```javascript
46
+ const file1 = await app.openFile("testfile1.fits");
47
+ const file2 = await app.appendFile("testfile2.fits");
48
+ const file3 = await app.appendFile("testfile3.fits");
49
+ ```
50
+
51
+ The active image can be changed with <ApiLink path="/.-stores/class/AppStore/#updateActiveImageByFrame">`updateActiveImageByFrame`</ApiLink>, as well as the wrapper functions <ApiLink path="/.-stores/class/AppStore/#setActiveImageByFileId">`setActiveImageByFileId`</ApiLink> and <ApiLink path="/.-stores/class/AppStore/#setActiveImageByIndex">`setActiveImageByIndex`</ApiLink>.
52
+
53
+ ```javascript
54
+ app.setActiveImageByIndex(0);
55
+ app.setActiveImageByFileId(file2.frameInfo.fileId);
56
+ app.updateActiveImageByFrame(file3);
57
+ ```
58
+
59
+ ## Closing images
60
+
61
+ <ApiLink path="/.-stores/class/AppStore/#closeCurrentFile">`closeCurrentFile`</ApiLink> closes the active image. There will be no user confirmation if the active image serves as the spatial reference image and there are other images matched
62
+ to it.
63
+
64
+ ```javascript
65
+ app.closeCurrentFile();
66
+ ```
67
+
68
+ <ApiLink path="/.-stores/class/AppStore/#closeFile">`closeFile`</ApiLink> takes an optional boolean argument to control whether user confirmation is required if other images are matched to the given file. This defaults to true. `await` is required
69
+ to delay execution until the user confirms.
70
+
71
+ ```javascript
72
+ await app.closeFile(file1);
73
+ app.closeFile(file1, false); // No user confirmation
74
+ ```
75
+
76
+ <ApiLink path="/.-stores/class/AppStore/#closeOtherFiles">`closeOtherFiles`</ApiLink> closes all images other than the given file.
77
+
78
+ ```javascript
79
+ app.closeOtherFiles(file2);
80
+ ```
81
+
82
+ For all functions and objects available in the <ApiLink path="/.-stores/class/AppStore">`app`</ApiLink> object, please refer to the <ApiLink path="/.-stores/class/AppStore">API documentation</ApiLink>.
@@ -0,0 +1,49 @@
1
+ ---
2
+ sidebar_position: 4
3
+ ---
4
+
5
+ import Link from "@docusaurus/Link";
6
+
7
+ # Regions
8
+
9
+ Actions related to regions. In the following examples, we assume that an image is loaded as
10
+
11
+ ```javascript
12
+ const file = await app.openFile("my_image.fits");
13
+ ```
14
+
15
+ ## Creating regions
16
+
17
+ Regions on a specific image are accessible via <ApiLink path="/.-stores/class/RegionSetStore">`RegionSetStore`</ApiLink> under each image. Each region is represented by a <ApiLink path="/.-stores/class/RegionStore">`RegionStore`</ApiLink> object.
18
+
19
+ ```javascript
20
+ console.log(file.regionSet.regions); // View all regions
21
+ console.log(file.regionSet.selectedRegion); // View the selected region
22
+ ```
23
+
24
+ <ApiLink path="/.-stores/class/RegionSetStore/#addRegionAsync">`addRegionAsync`</ApiLink> creates regions on the loaded image with available [region types](https://carta-protobuf.readthedocs.io/en/latest/enums.html#regiontype).
25
+
26
+ ```javascript
27
+ const regionSet = file.regionSet;
28
+ const region = await regionSet.addRegionAsync(3, [{x: [center x], y: [center y]}, {x: [width], y: [height]}]); // Add a rectangle region
29
+ const region2 = await regionSet.addRegionAsync(1, [{x: [start x], y: [start y]}, {x: [end x], y: [end y]}]); // Add a line region
30
+ ```
31
+
32
+ ## Changing region properties
33
+
34
+ Properties of a region can be modified using the <ApiLink path="/.-stores/class/RegionStore">`RegionStore`</ApiLink> object.
35
+
36
+ ```javascript
37
+ // ex: a rectangle region
38
+ region.setCenter({x: 0, y: 0}); // Move the region to position (0, 0)
39
+ region.setSize({x: 100, y: 100}); // Resize to 100 x 100 pixels
40
+ region.setColor("#ffffff"); // Change the color to white
41
+ ```
42
+
43
+ ## Importing regions
44
+
45
+ <ApiLink path="/.-stores/class/AppStore/#importRegion">`importRegion`</ApiLink> imports regions to the active image with the provided path, filename, and [file type](https://carta-protobuf.readthedocs.io/en/latest/enums.html#filetype) enum.
46
+
47
+ ```javascript
48
+ await app.importRegion("[path]", "[filename]", 1); // File type: CRTF
49
+ ```
@@ -0,0 +1,7 @@
1
+ {
2
+ "label": "Contributing",
3
+ "position": 3,
4
+ "link": {
5
+ "type": "generated-index"
6
+ }
7
+ }
@@ -0,0 +1,61 @@
1
+ ---
2
+ sidebar_position: 1
3
+ ---
4
+
5
+ # Developer tips
6
+
7
+ Useful commands for development.
8
+
9
+ ## Checking and fixing code format
10
+
11
+ To check the code format:
12
+
13
+ ```
14
+ npm run checkformat
15
+ ```
16
+
17
+ To automatically fix the code format:
18
+
19
+ ```
20
+ npm run reformat
21
+ ```
22
+
23
+ ## Code linting
24
+
25
+ ESLint is applied to identify program errors and to check for the format of imported packages and TSDoc documentation.
26
+ To run the lint checks:
27
+
28
+ ```
29
+ npm run check-eslint
30
+ ```
31
+
32
+ To automatically fix the identified errors, particularly those related to import package formats:
33
+
34
+ ```
35
+ npm run fix-eslint
36
+ ```
37
+
38
+ ## Git hooks
39
+
40
+ This repository uses Husky and lint-staged to run checks automatically during commit and push.
41
+
42
+ - `pre-commit`: runs Prettier on staged files in `src/` (repo root Prettier) and on staged files in `docs_website/` using `docs_website/node_modules/.bin/prettier`, and runs ESLint auto-fix on staged JS/TS files in `src/`.
43
+ - `pre-push`: runs `npm run check-eslint` and `npm run checkformat`, and additionally runs `npm --prefix docs_website run checkformat` when pushed commits include `docs_website/` changes.
44
+
45
+ Hooks are installed automatically when running:
46
+
47
+ ```
48
+ npm install
49
+ ```
50
+
51
+ If install scripts are skipped (for example, `npm ci --ignore-scripts`), run:
52
+
53
+ ```
54
+ npm run prepare
55
+ ```
56
+
57
+ If you modify files under `docs_website/`, make sure docs dependencies are installed first:
58
+
59
+ ```
60
+ npm --prefix docs_website install
61
+ ```