From 1978fe50a2aa35d44317d8921dec21307961e234 Mon Sep 17 00:00:00 2001 From: Tien-Hao Chang Date: Thu, 6 Jun 2024 12:59:42 +0800 Subject: [PATCH 01/32] support image coordinates for images with valid WCS headers --- src/components/ImageView/Overlay/OverlayComponent.tsx | 6 +++--- src/components/ImageView/Toolbar/ToolbarComponent.tsx | 4 +++- src/stores/Frame/FrameStore.ts | 10 +++++++--- src/stores/OverlayStore/OverlayStore.ts | 7 ++++--- wasm_src/ast_wrapper/ast_wrapper.cc | 4 +--- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/components/ImageView/Overlay/OverlayComponent.tsx b/src/components/ImageView/Overlay/OverlayComponent.tsx index 2ccc8fd2aa..df647daaf7 100644 --- a/src/components/ImageView/Overlay/OverlayComponent.tsx +++ b/src/components/ImageView/Overlay/OverlayComponent.tsx @@ -5,7 +5,7 @@ import * as _ from "lodash"; import {observer} from "mobx-react"; import {CursorInfo, SPECTRAL_TYPE_STRING} from "models"; -import {AppStore, OverlayStore, PreferenceStore} from "stores"; +import {AppStore, OverlayStore, PreferenceStore, SystemType} from "stores"; import {FrameStore} from "stores/Frame"; import "./OverlayComponent.scss"; @@ -105,7 +105,7 @@ export class OverlayComponent extends React.Component { currentStyleString += `, Tol=${tolVal}`; } - if (!this.props.frame.validWcs) { + if (!this.props.frame.validWcs || settings.global.explicitSystem === SystemType.Image) { //Remove system and format entries currentStyleString = currentStyleString.replace(/System=.*?,/, "").replaceAll(/Format\(\d\)=.*?,/g, ""); } @@ -202,7 +202,7 @@ export class OverlayComponent extends React.Component { const formatStringX = this.props.overlaySettings.numbers.formatStringX; const formatStyingY = this.props.overlaySettings.numbers.formatStringY; const explicitSystem = this.props.overlaySettings.global.explicitSystem; - if (formatStringX !== undefined && formatStyingY !== undefined && explicitSystem !== undefined) { + if (formatStringX !== undefined && formatStyingY !== undefined && explicitSystem !== undefined && explicitSystem !== SystemType.Image) { AST.set(frame.wcsInfo, `Format(${frame.dirX})=${formatStringX}, Format(${frame.dirY})=${formatStyingY}, System=${explicitSystem},` + dirAxesSetting); } } diff --git a/src/components/ImageView/Toolbar/ToolbarComponent.tsx b/src/components/ImageView/Toolbar/ToolbarComponent.tsx index 757f35242c..3377b6faa7 100644 --- a/src/components/ImageView/Toolbar/ToolbarComponent.tsx +++ b/src/components/ImageView/Toolbar/ToolbarComponent.tsx @@ -33,7 +33,8 @@ export class ToolbarComponent extends React.Component { [SystemType.FK4, "FK4"], [SystemType.Galactic, "GAL"], [SystemType.Ecliptic, "ECL"], - [SystemType.ICRS, "ICRS"] + [SystemType.ICRS, "ICRS"], + [SystemType.Image, "IMG"] ]); private static readonly CoordinateSystemTooltip = new Map([ @@ -178,6 +179,7 @@ export class ToolbarComponent extends React.Component { this.handleCoordinateSystemClicked(SystemType.Galactic)} /> this.handleCoordinateSystemClicked(SystemType.Ecliptic)} /> this.handleCoordinateSystemClicked(SystemType.ICRS)} /> + this.handleCoordinateSystemClicked(SystemType.Image)} /> ); diff --git a/src/stores/Frame/FrameStore.ts b/src/stores/Frame/FrameStore.ts index 51e24e0013..180a51dee5 100644 --- a/src/stores/Frame/FrameStore.ts +++ b/src/stores/Frame/FrameStore.ts @@ -1494,8 +1494,12 @@ export class FrameStore { updateWcsSystem = (formatStringX: string, formatStyingY: string, explicitSystem: SystemType) => { if (formatStringX !== undefined && formatStyingY !== undefined && explicitSystem !== undefined) { - if (!(this.isPVImage && this.spectralAxis?.valid) && !(this.isSwappedZ && this.spectralAxis?.valid)) { - if (this.validWcs && this.wcsInfo) { + if (!(this.isPVImage && this.spectralAxis?.valid) && !(this.isSwappedZ && this.spectralAxis?.valid) && this.validWcs && this.wcsInfo) { + if (explicitSystem === SystemType.Image) { + // Use base frame for image coordinates + AST.setI(this.wcsInfo, "Current", 1); + } else { + AST.setI(this.wcsInfo, "Current", 2); AST.set(this.wcsInfo, `Format(${this.dirX})=${formatStringX}, Format(${this.dirY})=${formatStyingY}, System=${explicitSystem}`); } } @@ -1908,7 +1912,7 @@ export class FrameStore { let cursorPosWCS, cursorPosFormatted; let precisionX = 0; let precisionY = 0; - if (this.validWcs || this.isYX || this.isPVImage || this.isUVImage || this.isSwappedZ) { + if ((this.validWcs || this.isYX || this.isPVImage || this.isUVImage || this.isSwappedZ) && this.overlayStore.global.explicitSystem !== SystemType.Image) { // We need to compare X and Y coordinates in both directions // to avoid a confusing drop in precision at rounding threshold const offsetBlock = [ diff --git a/src/stores/OverlayStore/OverlayStore.ts b/src/stores/OverlayStore/OverlayStore.ts index be79d3b9aa..02582bce67 100644 --- a/src/stores/OverlayStore/OverlayStore.ts +++ b/src/stores/OverlayStore/OverlayStore.ts @@ -32,7 +32,8 @@ export enum SystemType { FK4 = "FK4", FK5 = "FK5", Galactic = "GALACTIC", - ICRS = "ICRS" + ICRS = "ICRS", + Image = "Cartesian" } export enum NumberFormatType { @@ -101,7 +102,7 @@ export class OverlayGlobalSettings { astString.add("Tol", toFixed(this.tolerance / 100, 2), this.tolerance >= 0.001); // convert to fraction astString.add("System", this.explicitSystem); - if ((frame?.isXY || frame?.isYX) && !frame?.isPVImage && typeof this.explicitSystem !== "undefined") { + if ((frame?.isXY || frame?.isYX) && !frame?.isPVImage && typeof this.explicitSystem !== "undefined" && this.explicitSystem !== SystemType.Image) { if (this.system === SystemType.FK4) { astString.add("Equinox", "1950"); } else { @@ -1021,7 +1022,7 @@ export class OverlayStore { autorun(() => { this.setFormatsFromSystem(); AppStore.Instance.frames.forEach(frame => { - if (frame?.validWcs && frame?.wcsInfoForTransformation && this.global.explicitSystem) { + if (frame?.validWcs && frame?.wcsInfoForTransformation && this.global.explicitSystem && this.global.explicitSystem !== SystemType.Image) { AST.set(frame.wcsInfoForTransformation, `System=${this.global.explicitSystem}`); } }); diff --git a/wasm_src/ast_wrapper/ast_wrapper.cc b/wasm_src/ast_wrapper/ast_wrapper.cc index e2913d51f0..9c4cdecae2 100644 --- a/wasm_src/ast_wrapper/ast_wrapper.cc +++ b/wasm_src/ast_wrapper/ast_wrapper.cc @@ -204,9 +204,7 @@ EMSCRIPTEN_KEEPALIVE AstFrameSet* createTransformedFrameset(AstFrameSet* wcsinfo EMSCRIPTEN_KEEPALIVE AstFrameSet* initDummyFrame() { - double offsets[] = {-1, -1}; - AstFrameSet* frameSet = astFrameSet(astFrame(2, ""), ""); - astAddFrame(frameSet, 1, astShiftMap(2, offsets, ""), astFrame(2, "Label(1)=X Coordinate,Label(2)=Y Coordinate,Domain=PIXEL")); + AstFrameSet* frameSet = astFrameSet(astFrame(2, "Label(1)=X Coordinate,Label(2)=Y Coordinate,Domain=PIXEL"), ""); return frameSet; } From 6fe30a573c911f499ce398cc0be5ffed8a86e2f0 Mon Sep 17 00:00:00 2001 From: Tien-Hao Chang Date: Mon, 24 Jun 2024 15:44:05 +0800 Subject: [PATCH 02/32] set labels of pixel frames --- wasm_src/ast_wrapper/ast_wrapper.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wasm_src/ast_wrapper/ast_wrapper.cc b/wasm_src/ast_wrapper/ast_wrapper.cc index 9c4cdecae2..61836e1c01 100644 --- a/wasm_src/ast_wrapper/ast_wrapper.cc +++ b/wasm_src/ast_wrapper/ast_wrapper.cc @@ -52,6 +52,9 @@ EMSCRIPTEN_KEEPALIVE AstFrameSet* getFrameFromFitsChan(AstFitsChan* fitschan, bo return nullptr; } + AstFrame* pixFrame = static_cast astGetFrame(frameSet, 1); + astSet(pixFrame, "Label(1)=X Coordinate,Label(2)=Y Coordinate"); + // work around for missing CTYPE1 & CTYPE2 if (checkSkyDomain) { const char *domain = astGetC(frameSet, "Domain"); @@ -104,7 +107,7 @@ EMSCRIPTEN_KEEPALIVE AstFrameSet* getSkyFrameSet(AstFrameSet* frameSet) } // Create 2D base frame - AstFrame *baseframe = astFrame(2, "Title=Pixel Coordinates,Domain=GRID,Label(1)=Pixel axis 1,Label(2)=Pixel axis 2"); + AstFrame *baseframe = astFrame(2, "Title=Pixel Coordinates,Domain=GRID,Label(1)=X Coordinate,Label(2)=Y Coordinate"); if (!baseframe) { cout << "Create 2D base frame failed." << endl; @@ -204,7 +207,7 @@ EMSCRIPTEN_KEEPALIVE AstFrameSet* createTransformedFrameset(AstFrameSet* wcsinfo EMSCRIPTEN_KEEPALIVE AstFrameSet* initDummyFrame() { - AstFrameSet* frameSet = astFrameSet(astFrame(2, "Label(1)=X Coordinate,Label(2)=Y Coordinate,Domain=PIXEL"), ""); + AstFrameSet* frameSet = astFrameSet(astFrame(2, "Label(1)=X Coordinate,Label(2)=Y Coordinate,Domain=GRID"), ""); return frameSet; } From c576934862eff96b3dc1a94359adb2c1d94e9dc0 Mon Sep 17 00:00:00 2001 From: Tien-Hao Chang Date: Mon, 24 Jun 2024 16:58:40 +0800 Subject: [PATCH 03/32] disable wcs inputs when the system coordinates is IMG --- .../Shared/CoordNumericInput/CoordNumericInput.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/Shared/CoordNumericInput/CoordNumericInput.tsx b/src/components/Shared/CoordNumericInput/CoordNumericInput.tsx index 0a510a7659..0958195d54 100644 --- a/src/components/Shared/CoordNumericInput/CoordNumericInput.tsx +++ b/src/components/Shared/CoordNumericInput/CoordNumericInput.tsx @@ -1,6 +1,6 @@ import {Position, Tooltip} from "@blueprintjs/core"; -import {AppStore, NUMBER_FORMAT_LABEL} from "stores"; +import {AppStore, NUMBER_FORMAT_LABEL, SystemType} from "stores"; import {CoordinateMode} from "stores/Frame"; import {SafeNumericInput} from ".."; @@ -131,6 +131,14 @@ export const CoordNumericInput = ({coord, inputType, value, onChange, valueWcs, if (coord === CoordinateMode.Image) { return ; } else { - return ; + return ( + + ); } }; From f761d4d9df96e31231ac6b027b57736b2f675407 Mon Sep 17 00:00:00 2001 From: Tien-Hao Chang Date: Thu, 4 Jul 2024 12:33:07 +0800 Subject: [PATCH 04/32] minor change for AST plot speed --- src/components/ImageView/Overlay/OverlayComponent.tsx | 2 +- src/stores/OverlayStore/OverlayStore.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/ImageView/Overlay/OverlayComponent.tsx b/src/components/ImageView/Overlay/OverlayComponent.tsx index 4eb3a16dce..66a0a8267c 100644 --- a/src/components/ImageView/Overlay/OverlayComponent.tsx +++ b/src/components/ImageView/Overlay/OverlayComponent.tsx @@ -104,7 +104,7 @@ export class OverlayComponent extends React.Component { currentStyleString += `, Tol=${tolVal}`; } - if (!frame.validWcs || settings.global.explicitSystem === SystemType.Image) { + if (!frame.validWcs) { //Remove system and format entries currentStyleString = currentStyleString.replace(/System=.*?,/, "").replaceAll(/Format\(\d\)=.*?,/g, ""); } diff --git a/src/stores/OverlayStore/OverlayStore.ts b/src/stores/OverlayStore/OverlayStore.ts index 03d385dae9..9b5e31eb41 100644 --- a/src/stores/OverlayStore/OverlayStore.ts +++ b/src/stores/OverlayStore/OverlayStore.ts @@ -100,7 +100,9 @@ export class OverlayGlobalSettings { astString.add("Labelling", this.labelType); astString.add("Color", AstColorsIndex.GLOBAL); astString.add("Tol", toFixed(this.tolerance / 100, 2), this.tolerance >= 0.001); // convert to fraction - astString.add("System", this.explicitSystem); + if (typeof this.explicitSystem !== "undefined" && this.explicitSystem !== SystemType.Image) { + astString.add("System", this.explicitSystem); + } if ((frame?.isXY || frame?.isYX) && !frame?.isPVImage && typeof this.explicitSystem !== "undefined" && this.explicitSystem !== SystemType.Image) { if (this.system === SystemType.FK4) { From 4d0bf1991ff8fc6d78513c53194c61c8ad57086a Mon Sep 17 00:00:00 2001 From: Tien-Hao Chang Date: Thu, 4 Jul 2024 12:34:57 +0800 Subject: [PATCH 05/32] fix regression of missing AST grid for no wcs info frame after swithing active frames --- src/stores/AppStore/AppStore.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/stores/AppStore/AppStore.ts b/src/stores/AppStore/AppStore.ts index 6be6b4104f..dc00907f75 100644 --- a/src/stores/AppStore/AppStore.ts +++ b/src/stores/AppStore/AppStore.ts @@ -1988,6 +1988,8 @@ export class AppStore { this.contourDataSource = frame; } } + + this.overlayStore.setDefaultsFromFrame(this.activeFrame); } else { this.widgetsStore.updateImageWidgetTitle(this.layoutStore.dockedLayout); } From e46779d47828c72c39147a0f01c8d8c9d9ee4de9 Mon Sep 17 00:00:00 2001 From: Tien-Hao Chang Date: Thu, 4 Jul 2024 12:40:37 +0800 Subject: [PATCH 06/32] fix warning of searching radius in degree for pixel coordinate frames --- src/stores/CatalogOnlineQuery/CatalogOnlineQueryConfigStore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/CatalogOnlineQuery/CatalogOnlineQueryConfigStore.ts b/src/stores/CatalogOnlineQuery/CatalogOnlineQueryConfigStore.ts index abd8134354..eb67dfc1eb 100644 --- a/src/stores/CatalogOnlineQuery/CatalogOnlineQueryConfigStore.ts +++ b/src/stores/CatalogOnlineQuery/CatalogOnlineQueryConfigStore.ts @@ -258,7 +258,7 @@ export class CatalogOnlineQueryConfigStore { @computed get searchRadiusInDegree(): number { const activeFrame = this.activeFrame; - if (activeFrame) { + if (activeFrame?.validWcs && OverlayStore.Instance.global.explicitSystem !== SystemType.Image) { const requiredFrameView = activeFrame.requiredFrameView; const diagonal1 = this.calculateDistanceFromPixelCoord({x: requiredFrameView.xMax, y: requiredFrameView.yMax}, {x: requiredFrameView.xMin, y: requiredFrameView.yMin}, true); const diagonal2 = this.calculateDistanceFromPixelCoord({x: requiredFrameView.xMin, y: requiredFrameView.yMax}, {x: requiredFrameView.xMax, y: requiredFrameView.yMin}, true); From 1e1ef6fb501b00cae39487959a8bff1521ecebd2 Mon Sep 17 00:00:00 2001 From: Tien-Hao Chang Date: Fri, 5 Jul 2024 16:21:15 +0800 Subject: [PATCH 07/32] fix spatial matching for the FrameSet's current frame --- wasm_src/ast_wrapper/ast_wrapper.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wasm_src/ast_wrapper/ast_wrapper.cc b/wasm_src/ast_wrapper/ast_wrapper.cc index 61836e1c01..0325cee5f9 100644 --- a/wasm_src/ast_wrapper/ast_wrapper.cc +++ b/wasm_src/ast_wrapper/ast_wrapper.cc @@ -183,10 +183,10 @@ EMSCRIPTEN_KEEPALIVE AstFrameSet* createTransformedFrameset(AstFrameSet* wcsinfo return nullptr; } - AstFrame* pixFrame = static_cast astGetFrame(wcsinfo, 1); + AstFrame* pixFrame = static_cast astGetFrame(wcsinfo, AST__BASE); AstFrame* pixFrameCopy = static_cast astCopy(pixFrame); - AstFrame* skyFrame = static_cast astGetFrame(wcsinfo, 2); - AstMapping* pixToSkyMapping = static_cast astGetMapping(wcsinfo, 1, 2); + AstFrame* skyFrame = static_cast astGetFrame(wcsinfo, AST__CURRENT); + AstMapping* pixToSkyMapping = static_cast astGetMapping(wcsinfo, AST__BASE, AST__CURRENT); AstFrameSet* wcsInfoTransformed = astFrameSet(pixFrame, ""); // 2D shifts From c2b410be4629897342936c070857a5df586ed1e6 Mon Sep 17 00:00:00 2001 From: Tien-Hao Chang Date: Thu, 1 Aug 2024 13:20:24 +0800 Subject: [PATCH 08/32] fixed relative coordinates for pixel coordinates --- .../ImageView/Overlay/OverlayComponent.tsx | 2 +- src/stores/Frame/FrameStore.ts | 6 ++++-- wasm_src/ast_wrapper/ast_wrapper.cc | 13 +++++++++++++ wasm_src/ast_wrapper/index.d.ts | 1 + wasm_src/ast_wrapper/post.ts | 1 + 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/components/ImageView/Overlay/OverlayComponent.tsx b/src/components/ImageView/Overlay/OverlayComponent.tsx index 5378cb42c1..d290a8d997 100644 --- a/src/components/ImageView/Overlay/OverlayComponent.tsx +++ b/src/components/ImageView/Overlay/OverlayComponent.tsx @@ -74,7 +74,7 @@ export class OverlayComponent extends React.Component { AST.setI(tempWcsInfo, "Current", 2); } - if (frame.isOffsetCoord) { + if (frame.isOffsetCoord && AppStore.Instance.overlayStore.global.explicitSystem !== SystemType.Image) { const fovSizeInArcsec = frame.getWcsSizeInArcsec(frame.fovSize); const viewSize = fovSizeInArcsec.x > fovSizeInArcsec.y ? fovSizeInArcsec.y : fovSizeInArcsec.x; const factor = 2; // jump factor diff --git a/src/stores/Frame/FrameStore.ts b/src/stores/Frame/FrameStore.ts index 112661257e..cffdc09ea1 100644 --- a/src/stores/Frame/FrameStore.ts +++ b/src/stores/Frame/FrameStore.ts @@ -2185,8 +2185,8 @@ export class FrameStore { @action private createWcsInfoShifted = () => { if (this.spatialReference) { this.spatialReference.createWcsInfoShifted(); - } else { - if (this.wcsInfo && this.offsetCenter) { + } else if (this.wcsInfo && this.offsetCenter) { + if (AppStore.Instance.overlayStore.global.explicitSystem !== SystemType.Image) { const centerInRad = getUnformattedWCSPoint(this.wcsInfo, this.offsetCenter); if (centerInRad) { @@ -2198,6 +2198,8 @@ export class FrameStore { } } } + } else { + this.wcsInfoShifted = AST.createShiftmapPixelFrameset(this.wcsInfo, this.offsetCenter.x, this.offsetCenter.y); } } }; diff --git a/wasm_src/ast_wrapper/ast_wrapper.cc b/wasm_src/ast_wrapper/ast_wrapper.cc index 28f7149b31..32bd6f3e6b 100644 --- a/wasm_src/ast_wrapper/ast_wrapper.cc +++ b/wasm_src/ast_wrapper/ast_wrapper.cc @@ -222,6 +222,19 @@ EMSCRIPTEN_KEEPALIVE AstFrameSet* createShiftmapFrameset(AstFrameSet* wcsinfo, d return wcsinfoShifted; } +EMSCRIPTEN_KEEPALIVE AstFrameSet* createShiftmapPixelFrameset(AstFrameSet* wcsinfo, double offsetX, double offsetY) +{ + AstFrameSet* wcsinfoShifted = static_cast astCopy(wcsinfo); + + // 2D shifts + double offset[] = {-offsetX, -offsetY}; + AstShiftMap* shiftMap = astShiftMap(2, offset, ""); + + astAddFrame(wcsinfoShifted, AST__BASE, shiftMap, astFrame(2, "Label(1)=X Coordinate,Label(2)=Y Coordinate,Domain=GRID")); + + return wcsinfoShifted; +} + EMSCRIPTEN_KEEPALIVE AstFrameSet* initDummyFrame() { AstFrameSet* frameSet = astFrameSet(astFrame(2, "Label(1)=X Coordinate,Label(2)=Y Coordinate,Domain=GRID"), ""); diff --git a/wasm_src/ast_wrapper/index.d.ts b/wasm_src/ast_wrapper/index.d.ts index 0cd245b07b..7ec6bb9304 100644 --- a/wasm_src/ast_wrapper/index.d.ts +++ b/wasm_src/ast_wrapper/index.d.ts @@ -57,6 +57,7 @@ export function setI(obj: AstObject, attrib: string, value: number): void; export function setD(obj: AstObject, attrib: string, value: number): void; export function createTransformedFrameset(frameSet: FrameSet, offsetX: number, offsetY: number, angle: number, originX: number, originY: number, scaleX: number, scaleY: number); export function createShiftmapFrameset(frameSet: FrameSet, offsetX: number, offsetY: number); +export function createShiftmapPixelFrameset(frameSet: FrameSet, offsetX: number, offsetY: number); // Not exported fillTransformGrid() export function makeSwappedFrameSet(originFrameSet: FrameSet, dirAxis: number, spectralAxis: number, pixelZ: number, nsample: number): FrameSet; diff --git a/wasm_src/ast_wrapper/post.ts b/wasm_src/ast_wrapper/post.ts index b057644af2..7b407391e1 100644 --- a/wasm_src/ast_wrapper/post.ts +++ b/wasm_src/ast_wrapper/post.ts @@ -130,6 +130,7 @@ Module.setI = Module.cwrap("setI", null, ["number", "string", "number"]); Module.setD = Module.cwrap("setD", null, ["number", "string", "number"]); Module.createTransformedFrameset = Module.cwrap("createTransformedFrameset", "number", ["number", "number", "number", "number", "number", "number", "number", "number"]); Module.createShiftmapFrameset = Module.cwrap("createShiftmapFrameset", "number", ["number", "number"]); +Module.createShiftmapPixelFrameset = Module.cwrap("createShiftmapPixelFrameset", "number", ["number", "number"]); Module.fillTransformGrid = Module.cwrap("fillTransformGrid", "number", ["number", "number", "number", "number", "number", "number", "number", "number"]); Module.pointList = Module.cwrap("pointList", "number", ["number", "number", "number", "number", "number"]); Module.axPointList = Module.cwrap("axPointList", "number", ["number", "number", "number", "number", "number", "number", "number"]); From 0e21d6332d6575076f16d8ff39b967268bccb825 Mon Sep 17 00:00:00 2001 From: Tien-Hao Chang Date: Wed, 7 Aug 2024 15:52:21 +0800 Subject: [PATCH 09/32] fixed image coordinates for non-squre pixels images --- src/components/ImageView/Overlay/OverlayComponent.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ImageView/Overlay/OverlayComponent.tsx b/src/components/ImageView/Overlay/OverlayComponent.tsx index d290a8d997..b880c125c2 100644 --- a/src/components/ImageView/Overlay/OverlayComponent.tsx +++ b/src/components/ImageView/Overlay/OverlayComponent.tsx @@ -70,8 +70,8 @@ export class OverlayComponent extends React.Component { const scaleMapping = AST.scaleMap2D(1.0, 1.0 / frame.aspectRatio); const newFrame = AST.frame(2, "Domain=PIXEL"); AST.addFrame(tempWcsInfo, 1, scaleMapping, newFrame); - AST.setI(tempWcsInfo, "Base", 3); - AST.setI(tempWcsInfo, "Current", 2); + AST.setI(tempWcsInfo, "Base", frame.validWcs ? 3 : 2); + AST.setI(tempWcsInfo, "Current", frame.validWcs ? 2 : 1); } if (frame.isOffsetCoord && AppStore.Instance.overlayStore.global.explicitSystem !== SystemType.Image) { From 7ca5837ee8f4af5962f2d9f5b8624e269401d6c7 Mon Sep 17 00:00:00 2001 From: Tien-Hao Chang Date: Wed, 21 Aug 2024 20:17:20 +0800 Subject: [PATCH 10/32] uppercased image system type and minorly refactored --- .../ImageView/Overlay/OverlayComponent.tsx | 2 +- .../Shared/CoordNumericInput/CoordNumericInput.tsx | 12 ++---------- .../CatalogOnlineQueryConfigStore.ts | 2 +- src/stores/Frame/FrameStore.ts | 4 ++-- src/stores/OverlayStore/OverlayStore.ts | 10 +++++++++- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/components/ImageView/Overlay/OverlayComponent.tsx b/src/components/ImageView/Overlay/OverlayComponent.tsx index b880c125c2..11bd9d3248 100644 --- a/src/components/ImageView/Overlay/OverlayComponent.tsx +++ b/src/components/ImageView/Overlay/OverlayComponent.tsx @@ -74,7 +74,7 @@ export class OverlayComponent extends React.Component { AST.setI(tempWcsInfo, "Current", frame.validWcs ? 2 : 1); } - if (frame.isOffsetCoord && AppStore.Instance.overlayStore.global.explicitSystem !== SystemType.Image) { + if (frame.isOffsetCoord && OverlayStore.Instance.isWcsCoordinates) { const fovSizeInArcsec = frame.getWcsSizeInArcsec(frame.fovSize); const viewSize = fovSizeInArcsec.x > fovSizeInArcsec.y ? fovSizeInArcsec.y : fovSizeInArcsec.x; const factor = 2; // jump factor diff --git a/src/components/Shared/CoordNumericInput/CoordNumericInput.tsx b/src/components/Shared/CoordNumericInput/CoordNumericInput.tsx index 0958195d54..bd52edbd63 100644 --- a/src/components/Shared/CoordNumericInput/CoordNumericInput.tsx +++ b/src/components/Shared/CoordNumericInput/CoordNumericInput.tsx @@ -1,6 +1,6 @@ import {Position, Tooltip} from "@blueprintjs/core"; -import {AppStore, NUMBER_FORMAT_LABEL, SystemType} from "stores"; +import {AppStore, NUMBER_FORMAT_LABEL} from "stores"; import {CoordinateMode} from "stores/Frame"; import {SafeNumericInput} from ".."; @@ -131,14 +131,6 @@ export const CoordNumericInput = ({coord, inputType, value, onChange, valueWcs, if (coord === CoordinateMode.Image) { return ; } else { - return ( - - ); + return ; } }; diff --git a/src/stores/CatalogOnlineQuery/CatalogOnlineQueryConfigStore.ts b/src/stores/CatalogOnlineQuery/CatalogOnlineQueryConfigStore.ts index 757c6fef39..abb08c9e95 100644 --- a/src/stores/CatalogOnlineQuery/CatalogOnlineQueryConfigStore.ts +++ b/src/stores/CatalogOnlineQuery/CatalogOnlineQueryConfigStore.ts @@ -260,7 +260,7 @@ export class CatalogOnlineQueryConfigStore { @computed get searchRadiusInDegree(): number { const activeFrame = this.activeFrame; - if (activeFrame?.validWcs && OverlayStore.Instance.global.explicitSystem !== SystemType.Image) { + if (activeFrame?.validWcs && OverlayStore.Instance.isWcsCoordinates) { const requiredFrameView = activeFrame.requiredFrameView; const diagonal1 = this.calculateDistanceFromPixelCoord({x: requiredFrameView.xMax, y: requiredFrameView.yMax}, {x: requiredFrameView.xMin, y: requiredFrameView.yMin}, true); const diagonal2 = this.calculateDistanceFromPixelCoord({x: requiredFrameView.xMin, y: requiredFrameView.yMax}, {x: requiredFrameView.xMax, y: requiredFrameView.yMin}, true); diff --git a/src/stores/Frame/FrameStore.ts b/src/stores/Frame/FrameStore.ts index cffdc09ea1..32cba23104 100644 --- a/src/stores/Frame/FrameStore.ts +++ b/src/stores/Frame/FrameStore.ts @@ -1929,7 +1929,7 @@ export class FrameStore { let cursorPosWCS, cursorPosFormatted; let precisionX = 0; let precisionY = 0; - if ((this.validWcs || this.isYX || this.isPVImage || this.isUVImage || this.isSwappedZ) && this.overlayStore.global.explicitSystem !== SystemType.Image) { + if ((this.validWcs || this.isYX || this.isPVImage || this.isUVImage || this.isSwappedZ) && this.overlayStore.isWcsCoordinates) { // We need to compare X and Y coordinates in both directions // to avoid a confusing drop in precision at rounding threshold const offsetBlock = [ @@ -2186,7 +2186,7 @@ export class FrameStore { if (this.spatialReference) { this.spatialReference.createWcsInfoShifted(); } else if (this.wcsInfo && this.offsetCenter) { - if (AppStore.Instance.overlayStore.global.explicitSystem !== SystemType.Image) { + if (this.overlayStore.isWcsCoordinates) { const centerInRad = getUnformattedWCSPoint(this.wcsInfo, this.offsetCenter); if (centerInRad) { diff --git a/src/stores/OverlayStore/OverlayStore.ts b/src/stores/OverlayStore/OverlayStore.ts index e62b25df33..d7b3cb4703 100644 --- a/src/stores/OverlayStore/OverlayStore.ts +++ b/src/stores/OverlayStore/OverlayStore.ts @@ -33,7 +33,7 @@ export enum SystemType { FK5 = "FK5", Galactic = "GALACTIC", ICRS = "ICRS", - Image = "Cartesian" + Image = "CARTESIAN" } export enum NumberFormatType { @@ -1247,4 +1247,12 @@ export class OverlayStore { return renderHeight > 1 ? renderHeight : 1; // return value > 1 to prevent crashing }; } + + @computed get isWcsCoordinates() { + return this.global.explicitSystem !== SystemType.Image; + } + + @computed get isImgCoordinates() { + return this.global.explicitSystem === SystemType.Image; + } } From 4c781db785ae407aa134c594b82d44c1ed8481db Mon Sep 17 00:00:00 2001 From: Tien-Hao Chang Date: Wed, 21 Aug 2024 20:24:26 +0800 Subject: [PATCH 11/32] fixed CatalogOnlineQueryComponent and genRegionWcsProperties --- .../OnlineDataQueryDialog/CatalogOnlineQueryComponent.tsx | 8 ++++++-- src/stores/Frame/FrameStore.ts | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/Dialogs/OnlineDataQueryDialog/CatalogOnlineQueryComponent.tsx b/src/components/Dialogs/OnlineDataQueryDialog/CatalogOnlineQueryComponent.tsx index ec37fea70f..fa37d9bcbd 100644 --- a/src/components/Dialogs/OnlineDataQueryDialog/CatalogOnlineQueryComponent.tsx +++ b/src/components/Dialogs/OnlineDataQueryDialog/CatalogOnlineQueryComponent.tsx @@ -144,7 +144,9 @@ export class CatalogQueryComponent extends React.Component { SystemType[key]) - .filter(sys => sys !== SystemType.Image)} + items={Object.values(SystemType).filter(sys => sys !== SystemType.Image)} activeItem={null} onItemSelect={type => appStore.overlayStore.global.setSystem(type)} itemRenderer={this.renderSysTypePopOver} From 32d4d18628fc7225c91d7dfa338f9354c9794f12 Mon Sep 17 00:00:00 2001 From: Tien-Hao Chang Date: Wed, 18 Dec 2024 15:29:00 +0800 Subject: [PATCH 31/32] minor adjustments --- .../Dialogs/WorkspaceDialog/WorkspaceDialogComponent.tsx | 2 +- src/stores/AppStore/AppStore.ts | 6 ++---- src/stores/Frame/FrameStore.ts | 2 ++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/Dialogs/WorkspaceDialog/WorkspaceDialogComponent.tsx b/src/components/Dialogs/WorkspaceDialog/WorkspaceDialogComponent.tsx index 72e6fda270..ac829e3114 100644 --- a/src/components/Dialogs/WorkspaceDialog/WorkspaceDialogComponent.tsx +++ b/src/components/Dialogs/WorkspaceDialog/WorkspaceDialogComponent.tsx @@ -69,7 +69,7 @@ export const WorkspaceDialogComponent = observer(() => { // TODO: to be removed after storing SystemType in workspace if (appStore.overlayStore.isImgCoordinates && appStore.frames.map(frame => frame.spatialReference !== null).includes(true)) { - AlertStore.Instance.showAlert("Not supporting save workspace with spatial matching in image cooordinates"); + AlertStore.Instance.showAlert("Saving workspace failed: not supporting spatial matching in image cooordinates."); return; } diff --git a/src/stores/AppStore/AppStore.ts b/src/stores/AppStore/AppStore.ts index e025ea1698..30610d9794 100644 --- a/src/stores/AppStore/AppStore.ts +++ b/src/stores/AppStore/AppStore.ts @@ -560,8 +560,9 @@ export class AppStore { }; this.telemetryService.addFileOpenEntry(ack.fileId, ack.fileInfo.type, ack.fileInfoExtended.width, ack.fileInfoExtended.height, ack.fileInfoExtended.depth, ack.fileInfoExtended.stokes, generated); + console.log("before constructor"); let newFrame = new FrameStore(frameInfo); - + console.log("after constructor"); // Place frame in frame array (replace frame with the same ID if it exists) const existingFrameIndex = this.imageViewConfigStore.getImageListIndex(ImageType.FRAME, ack.fileId); if (existingFrameIndex !== -1) { @@ -603,9 +604,6 @@ export class AppStore { this.setSpectralMatchingEnabled(newFrame, true); } if (this.preferenceStore.autoWCSMatching & WCSMatchingType.SPATIAL && this.spatialReference !== newFrame) { - if (this.overlayStore.isImgCoordinates) { - AST.setI(newFrame.wcsInfo, "Current", 1); - } this.setSpatialMatchingEnabled(newFrame, true); } if (this.preferenceStore.autoWCSMatching & WCSMatchingType.RASTER && this.rasterScalingReference !== newFrame) { diff --git a/src/stores/Frame/FrameStore.ts b/src/stores/Frame/FrameStore.ts index 007fff9629..87f938e205 100644 --- a/src/stores/Frame/FrameStore.ts +++ b/src/stores/Frame/FrameStore.ts @@ -1366,6 +1366,8 @@ export class FrameStore { } } + this.updateWcsSystem(this.overlayStore.numbers.formatStringX, this.overlayStore.numbers.formatStringY, this.overlayStore.global.explicitSystem); // for image coordinates selected + if (!this.wcsInfo) { this.logStore.addWarning(`Problem processing headers in file ${this.filename} for AST`, ["ast"]); this.wcsInfo = AST.initDummyFrame(); From 7bf309e1ce9e86ccdb6b27bc180146c5b8b4b146 Mon Sep 17 00:00:00 2001 From: Tien-Hao Chang Date: Wed, 18 Dec 2024 20:06:14 +0800 Subject: [PATCH 32/32] removed logs --- src/stores/AppStore/AppStore.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/stores/AppStore/AppStore.ts b/src/stores/AppStore/AppStore.ts index 30610d9794..73ae1337a8 100644 --- a/src/stores/AppStore/AppStore.ts +++ b/src/stores/AppStore/AppStore.ts @@ -560,9 +560,8 @@ export class AppStore { }; this.telemetryService.addFileOpenEntry(ack.fileId, ack.fileInfo.type, ack.fileInfoExtended.width, ack.fileInfoExtended.height, ack.fileInfoExtended.depth, ack.fileInfoExtended.stokes, generated); - console.log("before constructor"); let newFrame = new FrameStore(frameInfo); - console.log("after constructor"); + // Place frame in frame array (replace frame with the same ID if it exists) const existingFrameIndex = this.imageViewConfigStore.getImageListIndex(ImageType.FRAME, ack.fileId); if (existingFrameIndex !== -1) {