Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kuahchou/2396 new RESTFQ for moment #2404

Merged
merged 12 commits into from
Sep 9, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Added support for showing relative coordinates in image view ([[#681](https://github.com/CARTAvis/carta-frontend/issues/681)])
* Added a button for deleting all regions ([#1040](https://github.com/CARTAvis/carta-frontend/issues/1040)).
* Added support for loading remote FITS files from the hips2fits server ([#1379](https://github.com/CARTAvis/carta-backend/issues/1379)).
* Supported the customized rest frequency for the moment maps ([[#2396](https://github.com/CARTAvis/carta-frontend/issues/2396)]).
### Fixed
* Fixed ruler annotation matching bug ([#2242](https://github.com/CARTAvis/carta-frontend/issues/2242)).
* Fixed compass and ruler annotations update bug in the spatially matched image when changing the coordinate ([#2270](https://github.com/CARTAvis/carta-frontend/issues/2270)).
Expand Down
2 changes: 1 addition & 1 deletion protobuf
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@
flex-direction: row;

.#{$ns}-form-group {
margin-right: 10px;
margin: 0px;
.#{$ns}-label {
margin: 0px;
width: 3em;
}
}
Expand All @@ -51,5 +50,18 @@
.moment-generate {
float: right;
}

.freq-input {
display: flex;
flex-direction: row;

.#{$ns}-form-group {
margin-right: 10px;
.#{$ns}-input-group {
min-width: 130px;
width: 130px;
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import classNames from "classnames";
import {observer} from "mobx-react";

import {TaskProgressDialogComponent} from "components/Dialogs";
import {SafeNumericInput, SpectralSettingsComponent} from "components/Shared";
import {MOMENT_TEXT} from "models";
import {AppStore} from "stores";
import {ClearableNumericInputComponent, SafeNumericInput, SpectralSettingsComponent} from "components/Shared";
import {FrequencyUnit, MOMENT_TEXT} from "models";
import {AppStore, FrameStore} from "stores";
import {MomentSelectingMode, SpectralProfileWidgetStore} from "stores/Widgets";

import "./MomentGeneratorComponent.scss";
Expand Down Expand Up @@ -81,6 +81,28 @@ export class MomentGeneratorComponent extends React.Component<{widgetStore: Spec
return momentContent ? <MenuItem text={`${momentContent.tag}: ${momentContent.text}`} onClick={handleClick} key={moment} icon={this.props.widgetStore.isMomentSelected(moment) ? "tick" : "blank"} /> : undefined;
};

private renderRestFreqInput = (frame: FrameStore) => {
const disableCoordinateSetting = !frame || frame?.isPVImage || !frame?.isSpectralChannel;
const restFreqStore = frame?.restFreqStore;
return (
<div className="freq-input">
<ClearableNumericInputComponent
label="Rest frequency"
value={restFreqStore?.customRestFreq.value ?? NaN}
disabled={disableCoordinateSetting}
placeholder="Rest frequency"
selectAllOnFocus={true}
onValueChanged={restFreqStore?.setCustomVal}
onValueCleared={restFreqStore?.restoreDefaults}
resetDisabled={restFreqStore?.resetDisable}
tooltipContent={restFreqStore?.defaultInfo}
tooltipPlacement={"bottom"}
/>
<HTMLSelect disabled={disableCoordinateSetting} options={Object.values(FrequencyUnit)} value={restFreqStore?.customRestFreq.unit} onChange={ev => restFreqStore?.setCustomUnit(ev.currentTarget.value as FrequencyUnit)} />
</div>
);
};

private handleMomentTagRemove = (tag: string, index: number) => {
this.props.widgetStore.removeMomentByIndex(index);
};
Expand Down Expand Up @@ -173,6 +195,7 @@ export class MomentGeneratorComponent extends React.Component<{widgetStore: Spec
</div>
</FormGroup>
)}
<React.Fragment>{this.renderRestFreqInput(frame)}</React.Fragment>
</React.Fragment>
);

Expand Down
11 changes: 11 additions & 0 deletions src/stores/Frame/RestFreqStore/RestFreqStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,25 @@ export class RestFreqStore {
this.customRestFreq = defaultRestFreq;
}

/**
* Customize the rest frequency value. Set unit using {@link setCustomUnit}.
* @param val - Value of rest frequency.
*/
@action setCustomVal = (val: number) => {
this.customRestFreq.value = val;
};

/**
* Set the unit of the rest frequency. Customize the rest frequency value using {@link setCustomVal}.
* @param val - Unit of rest frequency in {@link FrequencyUnit}.
*/
@action setCustomUnit = (val: FrequencyUnit) => {
this.customRestFreq.unit = val;
};

/**
* Reset the rest frequency to the value and unit of the header.
*/
@action restoreDefaults = () => {
this.customRestFreq = this.headerRestFreq;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,22 @@ export class SpectralProfileWidgetStore extends RegionWidgetStore {
readonly profileSelectionStore: SpectralProfileSelectionStore;
readonly fittingStore: ProfileFittingStore;

/**
* Set region for the spectral profiler.
*
* @param fileId - File ID number.
* @param regionId - Region ID number.
*/
@override setRegionId = (fileId: number, regionId: number) => {
YuHsuan-Hwang marked this conversation as resolved.
Show resolved Hide resolved
this.regionIdMap.set(fileId, regionId);
this.clearXYBounds();
};

/**
* Set spectral coordinates.
*
* @param coordStr - A string of <i>Spectral type (unit)</i> like Frequency (GHz).
*/
@action setSpectralCoordinate = (coordStr: string) => {
YuHsuan-Hwang marked this conversation as resolved.
Show resolved Hide resolved
if (this.effectiveFrame?.setSpectralCoordinate(coordStr)) {
this.clearXBounds();
Expand All @@ -100,6 +111,11 @@ export class SpectralProfileWidgetStore extends RegionWidgetStore {
}
};

/**
* Set the spectral system.
*
* @param specsys - Spectral system {@link SpectralSystem}.
*/
@action setSpectralSystem = (specsys: SpectralSystem) => {
if (this.effectiveFrame?.setSpectralSystem(specsys)) {
this.clearXBounds();
Expand All @@ -110,6 +126,11 @@ export class SpectralProfileWidgetStore extends RegionWidgetStore {
this.intensityUnit = intensityUnitStr;
};

/**
* Select region for generating moment maps.
*
* @param regionId - Region ID number.
*/
@action selectMomentRegion = (regionId: number) => {
this.momentRegionId = regionId;
};
Expand All @@ -124,6 +145,12 @@ export class SpectralProfileWidgetStore extends RegionWidgetStore {
this.selectingMode = MomentSelectingMode.NONE;
};

/**
* Set the channel range for generating moment maps.
*
* @param min - Number of first channel.
* @param max - Number of last channel.
*/
@action setSelectedChannelRange = (min: number, max: number) => {
if (isFinite(min) && isFinite(max)) {
this.channelValueRange[0] = min;
Expand All @@ -150,16 +177,31 @@ export class SpectralProfileWidgetStore extends RegionWidgetStore {
}
};

/**
* Mask for generating moment maps.
*
* @param momentMask - enum {@link CARTA.MomentMask}.
*/
@action setMomentMask = (momentMask: CARTA.MomentMask) => {
this.momentMask = momentMask;
};

/**
* Add moments to generate maps.
*
* @param selected - Moment in {@link CARTA.Moment}.
*/
@action selectMoment = (selected: CARTA.Moment) => {
if (!this.selectedMoments.includes(selected)) {
this.selectedMoments.push(selected);
}
};

/**
* Delete moments to generate maps.
*
* @param deselected - Moment in {@link CARTA.Moment}.
*/
@action deselectMoment = (deselected: CARTA.Moment) => {
if (this.selectedMoments.includes(deselected)) {
this.selectedMoments = this.selectedMoments.filter(momentType => momentType !== deselected);
Expand All @@ -180,6 +222,9 @@ export class SpectralProfileWidgetStore extends RegionWidgetStore {
return this.selectedMoments.includes(momentType);
};

/**
* Request the moment maps.
*/
@action requestMoment = () => {
const frame = this.effectiveFrame;
if (frame && this.isMomentRegionValid) {
Expand All @@ -199,7 +244,8 @@ export class SpectralProfileWidgetStore extends RegionWidgetStore {
spectralRange: channelIndexRange,
mask: this.momentMask,
pixelRange: new CARTA.FloatBounds({min: this.maskRange[0], max: this.maskRange[1]}),
keep: this.keep
keep: this.keep,
restFreq: frame.restFreqStore?.restFreqInHz
};
frame.resetMomentRequestState();
frame.setIsRequestingMoments(true);
Expand All @@ -214,6 +260,9 @@ export class SpectralProfileWidgetStore extends RegionWidgetStore {
}
};

/**
* Cancel the moment maps request.
*/
@action requestingMomentCancelled = () => {
const frame = this.effectiveFrame;
if (frame) {
Expand Down Expand Up @@ -305,6 +354,11 @@ export class SpectralProfileWidgetStore extends RegionWidgetStore {
this.secondaryAxisCursorInfoVisible = val;
};

/**
* Keep previous moment maps.
*
* @param bool - A boolean. Set true to keep previous moment maps.
*/
@action setKeep = (bool: boolean) => {
this.keep = bool;
};
Expand Down
Loading