From bdf8e3abebf88158e1f0d4cf61bc9798e17b6689 Mon Sep 17 00:00:00 2001 From: roby Date: Tue, 4 Aug 2026 14:25:01 -0600 Subject: [PATCH] Firefly-2078: Refactor ImagePlotCntrl.js remove circular dependancies - break up ImagePlotCntlr.js and MultViewCntlr.js - VisConst.js, ImagePlotDispatch.js, visRoot.js - in addition put other constants in VisConst.js - phase 2: DrawLayerCntrl.js - includes response to feedback --- component-library/src/images/Coverage.jsx | 2 +- component-library/src/images/ImagePlot.jsx | 2 +- .../java/edu/caltech/ipac/astro/ibe/IBE.java | 6 +- .../caltech/ipac/firefly/data/FileInfo.java | 2 + .../ipac/visualize/net/IbeImageGetter.java | 6 +- src/firefly/js/Firefly.js | 5 +- src/firefly/js/api/ApiBuild.js | 92 +- src/firefly/js/api/ApiExpandedView.jsx | 4 +- src/firefly/js/api/ApiUtilImage.jsx | 17 +- src/firefly/js/api/ApiViewer.js | 11 +- .../js/api/webApiCommands/ImageCommands.js | 5 +- .../js/apps/alertviewer/AlertResultView.jsx | 2 +- .../js/apps/alertviewer/AlertUploadPanel.jsx | 5 +- src/firefly/js/charts/ChartsCntlr.js | 8 +- src/firefly/js/charts/TableStatsCntlr.js | 2 +- src/firefly/js/charts/ui/ChartSelectPanel.jsx | 2 +- src/firefly/js/charts/ui/ChartsContainer.jsx | 3 +- src/firefly/js/charts/ui/CombineChart.jsx | 3 +- src/firefly/js/charts/ui/MultiChartViewer.jsx | 3 +- .../js/charts/ui/PinnedChartContainer.jsx | 6 +- src/firefly/js/charts/ui/PlotlyToolbar.jsx | 5 +- .../js/charts/ui/options/BasicOptions.jsx | 2 +- src/firefly/js/core/AppDataCntlr.js | 17 +- src/firefly/js/core/ComponentCntlr.js | 2 +- src/firefly/js/core/CoreConst.js | 14 + src/firefly/js/core/ExternalAccessCntlr.js | 2 +- src/firefly/js/core/LayoutCntlr.js | 22 +- .../js/core/background/BackgroundUtil.js | 5 +- src/firefly/js/drawingLayers/Artifact.js | 34 +- src/firefly/js/drawingLayers/Catalog.js | 23 +- src/firefly/js/drawingLayers/CatalogUI.jsx | 3 +- src/firefly/js/drawingLayers/DistanceTool.js | 55 +- .../js/drawingLayers/DistanceToolUI.jsx | 2 +- .../js/drawingLayers/ExtractLineTool.js | 60 +- .../js/drawingLayers/ExtractPointsTool.js | 41 +- src/firefly/js/drawingLayers/FixedMarker.js | 5 +- .../js/drawingLayers/FixedPtControl.jsx | 2 +- src/firefly/js/drawingLayers/FootprintTool.js | 66 +- .../js/drawingLayers/FootprintToolUI.jsx | 8 +- src/firefly/js/drawingLayers/HiPSGrid.js | 16 +- src/firefly/js/drawingLayers/HiPSGridlUI.jsx | 3 +- src/firefly/js/drawingLayers/HiPSMOC.js | 45 +- src/firefly/js/drawingLayers/HiPSMOCUI.jsx | 2 +- .../drawingLayers/ImageLineBasedFootprint.js | 23 +- .../js/drawingLayers/ImageLineFootPrintUI.jsx | 2 +- src/firefly/js/drawingLayers/ImageOutline.js | 25 +- src/firefly/js/drawingLayers/ImageRoot.js | 14 +- src/firefly/js/drawingLayers/MarkerTool.js | 74 +- src/firefly/js/drawingLayers/MarkerToolUI.jsx | 3 +- .../js/drawingLayers/NorthUpCompass.js | 66 +- .../js/drawingLayers/PointSelection.js | 29 +- src/firefly/js/drawingLayers/RegionPlot.js | 35 +- .../js/drawingLayers/SearchSelectTool.js | 28 +- src/firefly/js/drawingLayers/SearchTarget.js | 26 +- src/firefly/js/drawingLayers/SelectArea.js | 51 +- src/firefly/js/drawingLayers/StatsPoint.js | 5 +- src/firefly/js/drawingLayers/WebGrid.js | 25 +- src/firefly/js/drawingLayers/WebGridUI.jsx | 2 +- .../js/drawingLayers/hpx/HpxCatalog.js | 57 +- .../js/drawingLayers/hpx/HpxCatalogUtil.js | 7 +- .../js/drawingLayers/hpx/TileDataMaker.jsx | 10 +- src/firefly/js/fieldGroup/FieldGroupCntlr.js | 2 +- .../js/metaConvert/DataProductsCntlr.js | 2 +- .../js/metaConvert/DataProductsFactory.js | 3 +- .../js/metaConvert/DataProductsWatcher.js | 43 +- .../js/metaConvert/DefaultConverter.js | 2 +- .../js/metaConvert/ImageDataProductsUtil.js | 35 +- .../js/metaConvert/TableDataProductUtils.js | 5 +- .../js/metaConvert/UploadAndAnalysis.js | 4 +- .../js/metaConvert/missions/ShaRequestList.js | 2 +- .../metaConvert/missions/WiseRequestList.js | 2 +- .../js/metaConvert/missions/ZtfRequestList.js | 2 +- .../js/metaConvert/vo/DatalinkProducts.js | 5 +- .../js/metaConvert/vo/ObsCoreConverter.js | 2 +- src/firefly/js/tables/HpxIndexCntlr.js | 2 +- src/firefly/js/tables/TablesCntlr.js | 3 +- src/firefly/js/templates/common/MainPanel.jsx | 2 +- .../templates/fireflyslate/FireflySlate.jsx | 8 +- .../fireflyslate/FireflySlateManager.js | 15 +- .../fireflyslate/GridLayoutPanel.jsx | 2 +- .../fireflyviewer/FireflyViewerManager.js | 21 +- .../templates/fireflyviewer/TriViewPanel.jsx | 2 +- .../js/templates/hydra/HydraManager.js | 18 +- .../js/templates/hydra/HydraViewer.jsx | 2 +- .../lightcurve/LcImageToolbarView.jsx | 8 +- .../lightcurve/LcImageViewerContainer.jsx | 4 +- .../js/templates/lightcurve/LcManager.js | 18 +- src/firefly/js/threadWorker/WorkerAccess.js | 2 +- src/firefly/js/ui/ActionsDropDownButton.jsx | 9 +- src/firefly/js/ui/CatalogSearchMethodType.jsx | 12 +- src/firefly/js/ui/ChartSelectDropdown.jsx | 2 +- src/firefly/js/ui/CutoutSizeDialog.jsx | 8 +- src/firefly/js/ui/DefaultSearchActions.js | 2 +- src/firefly/js/ui/FileUploadProcessor.jsx | 12 +- src/firefly/js/ui/FitsDownloadDialog.jsx | 6 +- src/firefly/js/ui/FitsRotationDialog.jsx | 6 +- src/firefly/js/ui/HiPSImageSelect.jsx | 31 +- src/firefly/js/ui/PointShapeSizePicker.jsx | 5 +- src/firefly/js/ui/ZoomOptionsPopup.jsx | 13 +- .../js/ui/dynamic/DLGeneratedDropDown.js | 12 +- src/firefly/js/ui/tap/SpatialSearch.jsx | 6 +- src/firefly/js/visualize/ChangePrime.js | 13 +- src/firefly/js/visualize/CoordUtil.js | 15 +- src/firefly/js/visualize/DrawLayerCntlr.js | 578 +----------- src/firefly/js/visualize/DrawLayerDispatch.js | 428 +++++++++ src/firefly/js/visualize/HiPSMocUtil.js | 3 +- .../js/visualize/ImViewFilterDisplay.js | 7 +- src/firefly/js/visualize/ImagePlotCntlr.js | 891 +----------------- src/firefly/js/visualize/ImagePlotDispatch.js | 739 +++++++++++++++ .../js/visualize/ImageViewerLayout.jsx | 27 +- src/firefly/js/visualize/MultiViewCntlr.js | 79 +- .../js/visualize/PlotCompleteMonitor.js | 27 +- src/firefly/js/visualize/PlotViewUtil.js | 61 +- src/firefly/js/visualize/RelatedDataUtil.js | 15 +- .../js/visualize/SearchRefinementTool.jsx | 23 +- src/firefly/js/visualize/VisConst.js | 306 +++++- src/firefly/js/visualize/VisMouseSync.js | 5 +- src/firefly/js/visualize/VisStoreRoots.js | 33 + src/firefly/js/visualize/WebPlot.js | 2 +- src/firefly/js/visualize/WebPlotRequest.js | 2 +- src/firefly/js/visualize/ZoomType.js | 35 - src/firefly/js/visualize/ZoomUtil.js | 31 +- .../__tests__/ImagePlotCntlr-test.js | 5 +- .../js/visualize/draw/CanvasWrapper.jsx | 2 +- src/firefly/js/visualize/draw/DrawLayer.js | 2 +- .../js/visualize/draw/DrawerComponent.jsx | 2 +- .../js/visualize/draw/ImageLineBasedObj.js | 7 +- src/firefly/js/visualize/draw/PointDataObj.js | 2 +- src/firefly/js/visualize/draw/ShapeDataObj.js | 11 +- .../js/visualize/draw/ShapeHighlight.js | 2 +- src/firefly/js/visualize/iv/EventLayer.jsx | 7 +- src/firefly/js/visualize/iv/ExpandedTools.jsx | 14 +- src/firefly/js/visualize/iv/HiPSTileCache.js | 2 +- .../js/visualize/iv/ImageExpandedMode.jsx | 8 +- src/firefly/js/visualize/iv/ImageRender.jsx | 2 +- src/firefly/js/visualize/iv/ImageViewer.jsx | 4 +- .../js/visualize/iv/ImageViewerDecorate.jsx | 5 +- src/firefly/js/visualize/iv/PlotTitle.jsx | 5 +- .../js/visualize/rawData/RawDataOps.js | 22 +- .../js/visualize/reducer/DrawLayerReducer.js | 79 +- .../js/visualize/reducer/HandlePlotAdmin.js | 33 +- .../js/visualize/reducer/HandlePlotChange.js | 77 +- .../visualize/reducer/HandlePlotCreation.js | 94 +- src/firefly/js/visualize/reducer/PlotView.js | 4 +- src/firefly/js/visualize/region/RegionArea.js | 13 +- .../js/visualize/region/RegionDescription.js | 12 +- .../visualize/region/RegionFileUploadView.jsx | 2 +- src/firefly/js/visualize/region/RegionTask.js | 15 +- .../visualize/saga/ActiveRowToImageWatcher.js | 18 +- .../js/visualize/saga/CatalogWatcher.js | 14 +- .../js/visualize/saga/CoverageUtil.jsx | 7 +- .../js/visualize/saga/CoverageWatcher.js | 37 +- src/firefly/js/visualize/saga/MOCWatcher.js | 13 +- .../js/visualize/saga/MouseReadoutWatch.js | 8 +- .../js/visualize/task/CreateTaskUtil.js | 23 +- .../js/visualize/task/ImageOverlayTask.js | 31 +- .../js/visualize/task/LSSTFootprintTask.js | 22 +- .../js/visualize/task/PlotAdminTask.js | 25 +- .../js/visualize/task/PlotChangeTask.js | 39 +- src/firefly/js/visualize/task/PlotHipsTask.js | 68 +- .../js/visualize/task/PlotImageTask.js | 28 +- src/firefly/js/visualize/task/WcsMatchTask.js | 31 +- src/firefly/js/visualize/task/ZoomTask.js | 19 +- .../js/visualize/ui/ApiFullImageDisplay.jsx | 5 +- .../visualize/ui/ApiToolbarImageDisplay.jsx | 2 +- .../js/visualize/ui/ColorBandPanel.jsx | 9 +- src/firefly/js/visualize/ui/ColorDialog.jsx | 13 +- .../js/visualize/ui/ColorPanelReducer.js | 18 +- .../ui/ColorRGBHuePreservingPanel.jsx | 7 +- .../visualize/ui/ColorTableDropDownView.jsx | 22 +- src/firefly/js/visualize/ui/CoveraeViewer.jsx | 14 +- .../js/visualize/ui/CtxToolbarFunctions.js | 30 +- .../js/visualize/ui/DrawLayerPanel.jsx | 10 +- .../js/visualize/ui/DrawLayerPanelView.jsx | 6 +- .../js/visualize/ui/DrawLayerUIComponents.jsx | 6 +- .../js/visualize/ui/ExpandedOptionsPopup.jsx | 3 +- .../js/visualize/ui/ExtractionWatchers.js | 20 +- .../js/visualize/ui/FileUploadViewPanel.jsx | 4 +- .../js/visualize/ui/FitsHeaderView.jsx | 19 +- .../ui/GroupedImageViewerContainer.jsx | 10 +- .../js/visualize/ui/HiPSSearchPanel.jsx | 4 +- .../js/visualize/ui/ImageCenterDropDown.jsx | 14 +- .../js/visualize/ui/ImageMetaDataToolbar.jsx | 2 +- .../visualize/ui/ImageMetaDataToolbarView.jsx | 3 +- .../js/visualize/ui/ImageSearchPanelV2.jsx | 17 +- .../js/visualize/ui/ImageStatsPopup.jsx | 11 +- .../js/visualize/ui/ImageTableRowViewer.jsx | 19 +- .../js/visualize/ui/MarkerDropDownView.jsx | 8 +- src/firefly/js/visualize/ui/MaskAddPanel.jsx | 14 +- .../js/visualize/ui/MatchLockDropDown.jsx | 3 +- .../js/visualize/ui/MouseReadPopoutAll.jsx | 10 +- src/firefly/js/visualize/ui/MouseReadout.jsx | 2 +- .../visualize/ui/MouseReadoutBottomLine.jsx | 2 +- .../visualize/ui/MouseReadoutOptionPopups.jsx | 5 +- .../js/visualize/ui/MouseReadoutUIUtil.js | 9 +- .../js/visualize/ui/MultiImageViewer.jsx | 16 +- .../js/visualize/ui/MultiImageViewerView.jsx | 3 +- .../js/visualize/ui/MultiItemViewerView.jsx | 2 +- .../visualize/ui/MultiViewStandardToolbar.jsx | 7 +- src/firefly/js/visualize/ui/PlotInfoPopup.js | 17 +- .../js/visualize/ui/PvControlsAndFeedback.jsx | 8 +- .../visualize/ui/SelectAreaUIComponents.jsx | 13 +- .../visualize/ui/SimpleLayerOnOffButton.jsx | 6 +- src/firefly/js/visualize/ui/SmallLegend.jsx | 2 +- .../js/visualize/ui/StretchDropDownView.jsx | 7 +- .../js/visualize/ui/TargetHiPSPanel.jsx | 21 +- .../visualize/ui/TargetHipsPanelToolbar.jsx | 10 +- src/firefly/js/visualize/ui/ThumbnailView.jsx | 2 +- .../js/visualize/ui/TriViewImageSection.jsx | 32 +- .../js/visualize/ui/VisCtxToolbarView.jsx | 15 +- .../js/visualize/ui/VisMiniToolbar.jsx | 9 +- .../js/visualize/ui/VisualSearchUtils.js | 22 +- src/firefly/js/visualize/ui/ZoomButton.jsx | 5 +- .../ui/extraction/ExtractionDialog.jsx | 37 +- .../ui/extraction/ExtractionTable.jsx | 2 +- .../ui/multiProduct/MultiProductChoice.jsx | 12 +- .../ui/multiProduct/MultiProductViewer.jsx | 6 +- 217 files changed, 3006 insertions(+), 3145 deletions(-) create mode 100644 src/firefly/js/core/CoreConst.js create mode 100644 src/firefly/js/visualize/DrawLayerDispatch.js create mode 100644 src/firefly/js/visualize/ImagePlotDispatch.js create mode 100644 src/firefly/js/visualize/VisStoreRoots.js delete mode 100644 src/firefly/js/visualize/ZoomType.js diff --git a/component-library/src/images/Coverage.jsx b/component-library/src/images/Coverage.jsx index 4e5ba6c66b..eadbe2dbcc 100644 --- a/component-library/src/images/Coverage.jsx +++ b/component-library/src/images/Coverage.jsx @@ -2,7 +2,7 @@ import React from 'react'; import { Box } from '@mui/joy'; import PropTypes from 'prop-types'; import { CoverageViewer } from 'firefly/visualize/ui/CoveraeViewer.jsx'; -import { DEFAULT_COVERAGE_VIEWER_ID } from 'firefly/visualize/PlotViewUtil.js'; +import {DEFAULT_COVERAGE_VIEWER_ID} from 'firefly/visualize/VisConst.js'; /** * Displays table coverage/footprint overlaid on a sky image as markers. diff --git a/component-library/src/images/ImagePlot.jsx b/component-library/src/images/ImagePlot.jsx index d146f36ed0..33db3ae6c9 100644 --- a/component-library/src/images/ImagePlot.jsx +++ b/component-library/src/images/ImagePlot.jsx @@ -2,7 +2,7 @@ import React, { useId, useEffect } from 'react'; import { Box } from '@mui/joy'; import PropTypes from 'prop-types'; import { ApiFullImageDisplay } from 'firefly/visualize/ui/ApiFullImageDisplay.jsx'; -import { dispatchPlotImage, dispatchDeletePlotView } from 'firefly/visualize/ImagePlotCntlr.js'; +import {dispatchDeletePlotView, dispatchPlotImage} from 'firefly/visualize/ImagePlotDispatch.js'; import WebPlotRequest from 'firefly/visualize/WebPlotRequest.js'; /** diff --git a/src/firefly/java/edu/caltech/ipac/astro/ibe/IBE.java b/src/firefly/java/edu/caltech/ipac/astro/ibe/IBE.java index 9428618b4c..5f44cd96b3 100644 --- a/src/firefly/java/edu/caltech/ipac/astro/ibe/IBE.java +++ b/src/firefly/java/edu/caltech/ipac/astro/ibe/IBE.java @@ -165,7 +165,11 @@ private void downloadViaUrlToFile(URL url, File results) throws IOException { HttpServiceInput addtlInfo = new HttpServiceInput(url.toString()); addtlInfo.setHeader("Accept", "text/plain"); - URLDownload.getDataToFile(url, results, addtlInfo.getCookies(), addtlInfo.getHeaders()); + FileInfo fi= URLDownload.getDataToFile(url, results, addtlInfo.getCookies(), addtlInfo.getHeaders()); + if (!fi.isSuccess()) { + throw new IOException(fi.getResponseCodeMsg(), + new FailedRequestException(fi.getResponseCodeMsg(),"network fail", fi.getResponseCode(), fi)); + } } catch (FailedRequestException e) { throw new IOException(e.getUserMessage(), e); } diff --git a/src/firefly/java/edu/caltech/ipac/firefly/data/FileInfo.java b/src/firefly/java/edu/caltech/ipac/firefly/data/FileInfo.java index f5c28839f1..7ca776e27f 100644 --- a/src/firefly/java/edu/caltech/ipac/firefly/data/FileInfo.java +++ b/src/firefly/java/edu/caltech/ipac/firefly/data/FileInfo.java @@ -11,6 +11,7 @@ import java.io.File; import java.io.Serializable; +import java.net.HttpURLConnection; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -129,6 +130,7 @@ public File getFile() { public boolean isBlank() { return StringUtils.getBoolean(attributes.get(BLANK), false); } public int getResponseCode() { return StringUtils.getInt(attributes.get(RESPONSE_CODE), 200); } public boolean isOK() { return getResponseCode()==200; } + public boolean isSuccess() { return getResponseCode()==200 || getResponseCode()==HttpURLConnection.HTTP_NOT_MODIFIED; } public String getResponseCodeMsg() { return attributes.get(RESPONSE_CODE_MSG); } diff --git a/src/firefly/java/edu/caltech/ipac/visualize/net/IbeImageGetter.java b/src/firefly/java/edu/caltech/ipac/visualize/net/IbeImageGetter.java index 89f4915cc2..46e10aca2c 100644 --- a/src/firefly/java/edu/caltech/ipac/visualize/net/IbeImageGetter.java +++ b/src/firefly/java/edu/caltech/ipac/visualize/net/IbeImageGetter.java @@ -146,9 +146,13 @@ else if (params instanceof PtfImageParams) { } } catch (IOException me){ + if (me.getCause() instanceof FailedRequestException fre) { + if (fre.getFileInfo() != null && !fre.getFileInfo().isSuccess()) { + throw new FailedRequestException(fre.getFileInfo().getResponseCodeMsg(), me); + } + } throw new FailedRequestException( "Could not parse results", "Details in exception", me ); } - } } diff --git a/src/firefly/js/Firefly.js b/src/firefly/js/Firefly.js index f7e28e5c60..eaf2b4f14c 100644 --- a/src/firefly/js/Firefly.js +++ b/src/firefly/js/Firefly.js @@ -28,8 +28,9 @@ import {bootstrapRedux, flux} from './core/ReduxFlux.js'; import {getOrCreateWsConn} from './core/messaging/WebSocketClient.js'; import {ActionEventHandler} from './core/messaging/MessageHandlers.js'; import {getJsonProperty, notifyServerAppInit} from './rpc/CoreServices.js'; -import {getPropsWith, mergeObjectOnly, getProp, toBoolean, documentReady,uuid} from './util/WebUtil.js'; -import {dispatchChangeTableAutoScroll, dispatchWcsMatch, visRoot} from './visualize/ImagePlotCntlr.js'; +import {getPropsWith, mergeObjectOnly, getProp, toBoolean, documentReady} from './util/WebUtil.js'; +import {dispatchChangeTableAutoScroll, dispatchWcsMatch} from './visualize/ImagePlotDispatch'; +import {visRoot} from './visualize/VisStoreRoots'; import {Logger} from './util/Logger.js'; import {evaluateWebApi, initWebApi, isUsingWebApi, WebApiStat} from './api/WebApi.js'; import {WebApiHelpInfoPage} from './ui/WebApiHelpInfoPage.jsx'; diff --git a/src/firefly/js/api/ApiBuild.js b/src/firefly/js/api/ApiBuild.js index 6a79a07ef8..5880a4a1ce 100644 --- a/src/firefly/js/api/ApiBuild.js +++ b/src/firefly/js/api/ApiBuild.js @@ -1,59 +1,63 @@ /* * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import React from 'react'; +import {ApiToolbarImageDisplay} from 'firefly/visualize/ui/ApiToolbarImageDisplay.jsx'; import {isString} from 'lodash'; -import {dispatchOnAppReady} from '../core/AppDataCntlr.js'; -import {ServerRequest } from '../data/ServerRequest.js'; -import {getJsonData } from '../rpc/SearchServicesJson.js'; +import React from 'react'; +import * as ChartsCntlr from '../charts/ChartsCntlr.js'; // Used for dispatch and action type constants import * as TableStatsCntlr from '../charts/TableStatsCntlr.js'; -import * as ChartsCntlr from '../charts/ChartsCntlr.js'; +import {ChartPanel} from '../charts/ui/ChartPanel.jsx'; +import {ChartsContainer} from '../charts/ui/ChartsContainer.jsx'; +import {MultiChartViewer} from '../charts/ui/MultiChartViewer.jsx'; +import {PlotlyWrapper} from '../charts/ui/PlotlyWrapper.jsx'; +import * as AppDataCntlr from '../core/AppDataCntlr.js'; +import {dispatchOnAppReady} from '../core/AppDataCntlr.js'; +import {APP_DATA_PATH} from '../core/CoreConst'; +import {dispatchAddCell, dispatchEnableSpecialViewer, dispatchRemoveCell} from '../core/LayoutCntlr.js'; +import {dispatchAddActionWatcher, dispatchAddSaga, dispatchAddTableTypeWatcherDef} from '../core/MasterSaga.js'; +import {ServerRequest} from '../data/ServerRequest.js'; +import {getJsonData} from '../rpc/SearchServicesJson.js'; +import * as HpxIndexCntlr from '../tables/HpxIndexCntlr.js'; import * as TablesCntlr from '../tables/TablesCntlr.js'; +import {TablePanel} from '../tables/ui/TablePanel.jsx'; +import {TablesContainer} from '../tables/ui/TablesContainer.jsx'; + +import {startTTFeatureWatchers} from '../templates/common/ttFeatureWatchers.js'; +import {FieldGroup} from '../ui/FieldGroup.jsx'; +import {showWorkspaceDialog, WorkspacePickerPopup} from '../ui/WorkspaceViewer.jsx'; +import * as DrawLayerDispatch from '../visualize/DrawLayerDispatch'; +import * as ImPlotDispatch from '../visualize/ImagePlotDispatch'; +import {ImageExpandedMode} from '../visualize/iv/ImageExpandedMode.jsx'; +import {ImageViewer} from '../visualize/iv/ImageViewer.jsx'; import * as ReadoutCntlr from '../visualize/MouseReadoutCntlr.js'; -import * as ImPlotCntlr from '../visualize/ImagePlotCntlr.js'; -import * as HpxIndexCntlr from '../tables/HpxIndexCntlr.js'; import * as MultiViewCntlr from '../visualize/MultiViewCntlr.js'; -import * as AppDataCntlr from '../core/AppDataCntlr.js'; -import * as DrawLayerCntlr from '../visualize/DrawLayerCntlr.js'; -import * as ComponentCntlr from '../core/ComponentCntlr.js'; -import {ApiExpandedView} from './ApiExpandedView.jsx'; -import {dispatchAddCell, dispatchRemoveCell, dispatchEnableSpecialViewer} from '../core/LayoutCntlr.js'; -import {dispatchAddSaga, dispatchAddActionWatcher, dispatchAddTableTypeWatcherDef} from '../core/MasterSaga.js'; -import {showWorkspaceDialog, WorkspacePickerPopup} from '../ui/WorkspaceViewer.jsx'; -import {FieldGroup} from '../ui/FieldGroup.jsx'; - -// Parts of the lowlevel api -import * as ApiUtil from './ApiUtil.js'; -import * as ApiUtilChart from './ApiUtilChart.jsx'; -import moreChartApi from './ApiUtilChart.jsx'; -import * as ApiUtilImage from './ApiUtilImage.jsx'; -import * as ApiUtilTable from './ApiUtilTable.jsx'; +import {getActiveRowToImageDef} from '../visualize/saga/ActiveRowToImageWatcher.js'; +import {getMocWatcherDef} from '../visualize/saga/MOCWatcher.js'; +import {ApiExpandedDisplay} from '../visualize/ui/ApiExpandedDisplay.jsx'; +import {ApiFullImageDisplay} from '../visualize/ui/ApiFullImageDisplay.jsx'; +import {ImageMetaDataToolbar} from '../visualize/ui/ImageMetaDataToolbar.jsx'; // UI component import {MultiImageViewer} from '../visualize/ui/MultiImageViewer.jsx'; -import {ImageViewer} from '../visualize/iv/ImageViewer.jsx'; -import {ImageMetaDataToolbar} from '../visualize/ui/ImageMetaDataToolbar.jsx'; import {MultiViewStandardToolbar} from '../visualize/ui/MultiViewStandardToolbar.jsx'; -import {ImageExpandedMode} from '../visualize/iv/ImageExpandedMode.jsx'; -import {ApiExpandedDisplay} from '../visualize/ui/ApiExpandedDisplay.jsx'; -import {ApiFullImageDisplay} from '../visualize/ui/ApiFullImageDisplay.jsx'; -import {ApiToolbarImageDisplay} from 'firefly/visualize/ui/ApiToolbarImageDisplay.jsx'; -import {TablesContainer} from '../tables/ui/TablesContainer.jsx'; -import {TablePanel} from '../tables/ui/TablePanel.jsx'; -import {ChartsContainer} from '../charts/ui/ChartsContainer.jsx'; -import {ChartPanel} from '../charts/ui/ChartPanel.jsx'; -import {MultiChartViewer} from '../charts/ui/MultiChartViewer.jsx'; -import {PlotlyWrapper} from '../charts/ui/PlotlyWrapper.jsx'; +import * as VisConst from '../visualize/VisConst.js'; +import {DRAWLAYER_PREFIX, IMAGE_MULTI_VIEW_PREFIX, PLOTS_PREFIX} from '../visualize/VisConst.js'; +import {ApiExpandedView} from './ApiExpandedView.jsx'; + // builds the highlevel api import {buildHighLevelApi} from './ApiHighlevelBuild.js'; -import {buildViewerApi} from './ApiViewer.js'; -import {startTTFeatureWatchers} from '../templates/common/ttFeatureWatchers.js'; -import {getActiveRowToImageDef} from '../visualize/saga/ActiveRowToImageWatcher.js'; -import {getMocWatcherDef} from '../visualize/saga/MOCWatcher.js'; + +// Parts of the lowlevel api +import * as ApiUtil from './ApiUtil.js'; +import * as ApiUtilChart from './ApiUtilChart.jsx'; +import moreChartApi from './ApiUtilChart.jsx'; +import * as ApiUtilImage from './ApiUtilImage.jsx'; +import * as ApiUtilTable from './ApiUtilTable.jsx'; +import {buildViewerApi} from './ApiViewer.js'; /** @@ -172,11 +176,11 @@ export function buildLowlevelAPI() { findActionType(TablesCntlr, TablesCntlr.RESULTS_PREFIX), findActionType(TablesCntlr, TablesCntlr.UI_PREFIX), findActionType(ReadoutCntlr, ReadoutCntlr.READOUT_PREFIX), - findActionType(MultiViewCntlr, MultiViewCntlr.IMAGE_MULTI_VIEW_PREFIX), - findActionType(ImPlotCntlr.default, ImPlotCntlr.PLOTS_PREFIX), + findActionType(VisConst, IMAGE_MULTI_VIEW_PREFIX), + findActionType(VisConst, PLOTS_PREFIX), + findActionType(VisConst, DRAWLAYER_PREFIX), findActionType(HpxIndexCntlr, HpxIndexCntlr.SPACIAL_HPX_INDX_PREFIX), - findActionType(AppDataCntlr, AppDataCntlr.APP_DATA_PATH), - findActionType(DrawLayerCntlr.default, DrawLayerCntlr.DRAWLAYER_PREFIX) + findActionType(AppDataCntlr, APP_DATA_PATH), ); @@ -187,10 +191,10 @@ export function buildLowlevelAPI() { findDispatch(TablesCntlr), findDispatch(ReadoutCntlr), findDispatch(MultiViewCntlr), - findDispatch(ImPlotCntlr), + findDispatch(ImPlotDispatch), findDispatch(HpxIndexCntlr), findDispatch(AppDataCntlr), - findDispatch(DrawLayerCntlr), + findDispatch(DrawLayerDispatch), {dispatchAddCell, dispatchRemoveCell, dispatchEnableSpecialViewer}, {dispatchAddSaga, dispatchAddActionWatcher, dispatchAddTableTypeWatcherDef} ); diff --git a/src/firefly/js/api/ApiExpandedView.jsx b/src/firefly/js/api/ApiExpandedView.jsx index e643fe56e3..be8c32c020 100644 --- a/src/firefly/js/api/ApiExpandedView.jsx +++ b/src/firefly/js/api/ApiExpandedView.jsx @@ -8,13 +8,13 @@ import {PinnedChartPanel} from '../charts/ui/PinnedChartContainer.jsx'; import {TablesContainer} from '../tables/ui/TablesContainer.jsx'; import {ChartsContainer} from '../charts/ui/ChartsContainer.jsx'; import {useStoreConnector} from '../ui/SimpleComponent.jsx'; -import {PINNED_CHART_VIEWER_ID} from '../visualize/MultiViewCntlr.js'; import {ApiExpandedDisplay} from '../visualize/ui/ApiExpandedDisplay.jsx'; import {FireflyRoot} from '../ui/FireflyRoot.jsx'; import {isDefined} from '../util/WebUtil.js'; -import {dispatchChangeExpandedMode, ExpandType} from '../visualize/ImagePlotCntlr.js'; import {dispatchSetLayoutMode, getExpandedMode, LO_MODE, LO_VIEW} from '../core/LayoutCntlr.js'; import {getExpandedChartProps} from '../charts/ChartsCntlr.js'; +import {dispatchChangeExpandedMode} from '../visualize/ImagePlotDispatch'; +import {ExpandType, PINNED_CHART_VIEWER_ID} from '../visualize/VisConst'; const closeFunc = () => { dispatchChangeExpandedMode(ExpandType.COLLAPSE); diff --git a/src/firefly/js/api/ApiUtilImage.jsx b/src/firefly/js/api/ApiUtilImage.jsx index 4c0076e516..6e6d254198 100644 --- a/src/firefly/js/api/ApiUtilImage.jsx +++ b/src/firefly/js/api/ApiUtilImage.jsx @@ -2,8 +2,7 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import React from 'react'; -import {visRoot} from '../visualize/ImagePlotCntlr.js'; +import {visRoot} from '../visualize/VisStoreRoots'; import {primePlot} from '../visualize/PlotViewUtil.js'; import {getBootstrapRegistry} from '../core/BootstrapRegistry'; import {RangeValues} from '../visualize/RangeValues.js'; @@ -26,7 +25,8 @@ import {RangeValues} from '../visualize/RangeValues.js'; export {RangeValues} from '../visualize/RangeValues.js'; export {WPConst, WebPlotRequest, findInvalidWPRKeys, confirmPlotRequest} from '../visualize/WebPlotRequest.js'; export {RequestType} from '../visualize/RequestType'; -export {ExpandType, visRoot} from '../visualize/ImagePlotCntlr.js'; +export {visRoot} from '../visualize/VisStoreRoots.js'; +export {ExpandType} from '../visualize/VisConst.js'; export {CysConverter} from '../visualize/CsysConverter.js'; export {CCUtil} from '../visualize/CsysConverter.js'; @@ -37,7 +37,7 @@ export {extensionAdd, extensionRemove} from '../core/ExternalAccessUtils.js'; export {makeWorldPt, makeScreenPt, makeImagePt, parsePt, parseAnyPt, parseWorldPt } from '../visualize/Point.js'; export {CoordinateSys} from '../visualize/CoordSys.js'; -export {IMAGE, NewPlotMode} from '../visualize/MultiViewCntlr'; +export {IMAGE, NewPlotMode} from '../visualize/VisConst.js'; /** @@ -77,15 +77,6 @@ export function setDrawLayerDefaults(drawLayerTypeId, defaults) { getBootstrapRegistry().setDrawLayerDefaults(drawLayerTypeId, defaults); } -/** - * @summary initialize the auto readout. Must be call once at the begging to get the popup readout running. - * @param {object} ReadoutComponent - either a PopupMouseReadoutMinimal or PopupMouseReadoutFull - * @param {object} props - a list of the properties - * @public - * @deprecated - * @function initAutoReadout - * @memberof firefly.util.image - */ export function initAutoReadout() {} diff --git a/src/firefly/js/api/ApiViewer.js b/src/firefly/js/api/ApiViewer.js index 5aee000fae..f6de970889 100644 --- a/src/firefly/js/api/ApiViewer.js +++ b/src/firefly/js/api/ApiViewer.js @@ -12,7 +12,8 @@ import Enum from 'enum'; import {WSCH} from '../core/History.js'; import {debug} from './ApiUtil.js'; import {dispatchRemoteAction} from '../core/JsonUtils.js'; -import {dispatchPlotImage, dispatchPlotHiPS} from '../visualize/ImagePlotCntlr.js'; +import {DEFAULT_FITS_VIEWER_ID, DEFAULT_PLOT2D_VIEWER_ID, PINNED_CHART_VIEWER_ID} from '../visualize/VisConst'; +import {dispatchPlotHiPS, dispatchPlotImage} from '../visualize/ImagePlotDispatch'; import {RequestType} from '../visualize/RequestType.js'; import {hashCode, getRootURL, modifyURLToFull} from '../util/WebUtil.js'; import {Logger} from '../util/Logger.js'; @@ -21,10 +22,12 @@ import {dispatchTableSearch, dispatchTableFetch} from '../tables/TablesCntlr.js import {dispatchChartAdd} from '../charts/ChartsCntlr.js'; import {makeFileRequest} from '../tables/TableRequestUtil.js'; import {uniqueChartId} from '../charts/ChartUtil.js'; -import {getWsChannel, getWsConnId, getConnectionCount, makeViewerChannel, - REINIT_APP, WS_CONN_UPDATED, GRAB_WINDOW_FOCUS, NOTIFY_REMOTE_APP_READY} from '../core/AppDataCntlr.js'; +import {REINIT_APP} from '../core/CoreConst'; +import { + getWsChannel, getWsConnId, getConnectionCount, makeViewerChannel, + WS_CONN_UPDATED, GRAB_WINDOW_FOCUS, NOTIFY_REMOTE_APP_READY +} from '../core/AppDataCntlr.js'; import {dispatchAddCell, dispatchEnableSpecialViewer, LO_VIEW} from '../core/LayoutCntlr.js'; -import {DEFAULT_FITS_VIEWER_ID, DEFAULT_PLOT2D_VIEWER_ID, PINNED_CHART_VIEWER_ID} from '../visualize/MultiViewCntlr.js'; import {dispatchAddActionWatcher} from '../core/MasterSaga.js'; import {WEB_API_CMD} from './WebApi.js'; diff --git a/src/firefly/js/api/webApiCommands/ImageCommands.js b/src/firefly/js/api/webApiCommands/ImageCommands.js index a53858e584..c2311dec2a 100644 --- a/src/firefly/js/api/webApiCommands/ImageCommands.js +++ b/src/firefly/js/api/webApiCommands/ImageCommands.js @@ -3,12 +3,11 @@ import {dispatchHideDropDown, dispatchShowDropDown} from '../../core/LayoutCntlr import {ServerParams} from '../../data/ServerParams.js'; import {makeTblRequest, MAX_ROW} from '../../tables/TableRequestUtil.js'; import {doFetchTable} from '../../tables/TableUtil.js'; -import {toBoolean} from '../../util/WebUtil.js'; +import {DEFAULT_FITS_VIEWER_ID} from '../../visualize/VisConst'; import WebPlotRequest, {findInvalidWPRKeys, WPConst} from '../../visualize/WebPlotRequest'; import {isEmpty,isArray,omit} from 'lodash'; -import {dispatchPlotHiPS, dispatchPlotImage} from '../../visualize/ImagePlotCntlr'; +import {dispatchPlotHiPS, dispatchPlotImage} from '../../visualize/ImagePlotDispatch'; import {RequestType} from '../../visualize/RequestType'; -import {DEFAULT_FITS_VIEWER_ID} from '../../visualize/MultiViewCntlr'; import {makeExamples, ReservedParams} from '../WebApi'; diff --git a/src/firefly/js/apps/alertviewer/AlertResultView.jsx b/src/firefly/js/apps/alertviewer/AlertResultView.jsx index c4d835ebea..cceeb3cd6f 100644 --- a/src/firefly/js/apps/alertviewer/AlertResultView.jsx +++ b/src/firefly/js/apps/alertviewer/AlertResultView.jsx @@ -8,7 +8,7 @@ import {MultiImageViewer} from '../../visualize/ui/MultiImageViewer.jsx'; import {useStoreConnector} from '../../ui/SimpleComponent.jsx'; import {getTblById, getTblIdsByGroup} from '../../tables/TableUtil.js'; -import {visRoot} from 'firefly/visualize/ImagePlotCntlr'; +import {visRoot} from '../../visualize/VisStoreRoots'; import {getPlotViewAry} from 'firefly/visualize/PlotViewUtil.js'; import {ALERT} from './AlertIDs.js'; diff --git a/src/firefly/js/apps/alertviewer/AlertUploadPanel.jsx b/src/firefly/js/apps/alertviewer/AlertUploadPanel.jsx index 4cd458990c..794731a4f6 100644 --- a/src/firefly/js/apps/alertviewer/AlertUploadPanel.jsx +++ b/src/firefly/js/apps/alertviewer/AlertUploadPanel.jsx @@ -14,7 +14,8 @@ import {ALERT} from './AlertIDs.js'; import {dispatchTableSearch} from 'firefly/tables/TablesCntlr'; import WebPlotRequest, {TitleOptions} from 'firefly/visualize/WebPlotRequest'; import RangeValues from 'firefly/visualize/RangeValues'; -import {dispatchDeletePlotView, dispatchPlotImage, dispatchWcsMatch, WcsMatchType} from 'firefly/visualize/ImagePlotCntlr'; +import {dispatchDeletePlotView, dispatchPlotImage, dispatchWcsMatch} from '../../visualize/ImagePlotDispatch'; +import {WcsMatchType} from '../../visualize/VisConst'; import {dispatchComponentStateChange} from 'firefly/core/ComponentCntlr'; import {removeTablesFromGroup} from 'firefly/tables/TableUtil'; import {dispatchChartRemove} from 'firefly/charts/ChartsCntlr'; @@ -149,7 +150,7 @@ function clearAlertProducts() { dispatchChartRemove(ALERT.CHART_1_ID); [ALERT.IMG_PLOT_1, ALERT.IMG_PLOT_2, ALERT.IMG_PLOT_3].forEach((plotId) => - dispatchDeletePlotView({plotId, holdWcsMatch: true}) + dispatchDeletePlotView({plotId}) ); } diff --git a/src/firefly/js/charts/ChartsCntlr.js b/src/firefly/js/charts/ChartsCntlr.js index 64c1e93173..20f5f74f65 100644 --- a/src/firefly/js/charts/ChartsCntlr.js +++ b/src/firefly/js/charts/ChartsCntlr.js @@ -11,14 +11,16 @@ import {Logger} from '../util/Logger.js'; import {getTblById, getColumns, isFullyLoaded, COL_TYPE} from '../tables/TableUtil.js'; import {dispatchAddActionWatcher} from '../core/MasterSaga.js'; import * as TablesCntlr from '../tables/TablesCntlr.js'; -import {DEFAULT_PLOT2D_VIEWER_ID, dispatchAddViewerItems, dispatchUpdateCustom, dispatchRemoveViewerItems, +import {dispatchAddViewerItems, dispatchUpdateCustom, dispatchRemoveViewerItems, getMultiViewRoot, getViewer} from '../visualize/MultiViewCntlr.js'; +import {DEFAULT_PLOT2D_VIEWER_ID} from '../visualize/VisConst'; import {applyDefaults, flattenAnnotations, formatColExpr, getPointIdx, getRowIdx, handleTableSourceConnections, clearChartConn, newTraceFrom, setupTableWatcher, HIGHLIGHTED_PROPS, SELECTED_PROPS, TBL_SRC_PATTERN, getSelIndexes, isSpectralOrder, combineAllTraceFrom} from './ChartUtil.js'; import {FilterInfo} from '../tables/FilterInfo.js'; import {SelectInfo} from '../tables/SelectInfo.js'; -import {REINIT_APP, getAppOptions} from '../core/AppDataCntlr.js'; +import {REINIT_APP} from '../core/CoreConst'; +import {getAppOptions} from '../core/AppDataCntlr.js'; import {showInfoPopup} from '../ui/PopupUtil.jsx'; import {makeHistogramParams, makeXYPlotParams, getDefaultChartProps} from './ChartUtil.js'; import {adjustColorbars, hasFireflyColorbar} from './dataTypes/FireflyHeatmap.js'; @@ -442,7 +444,7 @@ function chartFilterSelection(action) { y = `ifnull(${y},${lowerLimit})`; } - const multiArea = get(selection, 'multiArea') + const multiArea = get(selection, 'multiArea'); if (multiArea) { showInfoPopup('Filtering is only supported for one selection area.', 'Warning'); return; diff --git a/src/firefly/js/charts/TableStatsCntlr.js b/src/firefly/js/charts/TableStatsCntlr.js index 969868b11f..a32d37ebed 100644 --- a/src/firefly/js/charts/TableStatsCntlr.js +++ b/src/firefly/js/charts/TableStatsCntlr.js @@ -4,7 +4,7 @@ import {get, has, omit} from 'lodash'; import {updateSet, updateMerge} from '../util/WebUtil.js'; import ColValuesStatistics from './ColValuesStatistics.js'; -import {REINIT_APP} from '../core/AppDataCntlr.js'; +import {REINIT_APP} from '../core/CoreConst'; import {makeTblRequest, cloneRequest, MAX_ROW} from '../tables/TableRequestUtil.js'; import {getTblById, doFetchTable, getColumns, COL_TYPE} from '../tables/TableUtil.js'; diff --git a/src/firefly/js/charts/ui/ChartSelectPanel.jsx b/src/firefly/js/charts/ui/ChartSelectPanel.jsx index f58051eca3..676d6035c0 100644 --- a/src/firefly/js/charts/ui/ChartSelectPanel.jsx +++ b/src/firefly/js/charts/ui/ChartSelectPanel.jsx @@ -1,6 +1,7 @@ import React, {useContext, useEffect, useState} from 'react'; import PropTypes from 'prop-types'; import {get} from 'lodash'; +import {DEFAULT_PLOT2D_VIEWER_ID} from '../../visualize/VisConst'; import {FormPanel} from './../../ui/FormPanel.jsx'; import {getFieldVal} from '../../fieldGroup/FieldGroupUtils.js'; @@ -16,7 +17,6 @@ import {HeatmapOptions} from './options/HeatmapOptions.jsx'; import {SpectrumOptions} from './options/SpectrumOptions.jsx'; import {FireflyHistogramOptions} from './options/FireflyHistogramOptions.jsx'; import {RenderTreeIdCtx} from '../../ui/RenderTreeIdCtx.jsx'; -import {DEFAULT_PLOT2D_VIEWER_ID} from '../../visualize/MultiViewCntlr.js'; import {dispatchHideDialog, dispatchShowDialog} from '../../core/ComponentCntlr.js'; import DialogRootContainer from '../../ui/DialogRootContainer.jsx'; import {Box, Divider, Stack, Typography} from '@mui/joy'; diff --git a/src/firefly/js/charts/ui/ChartsContainer.jsx b/src/firefly/js/charts/ui/ChartsContainer.jsx index 2761adabe0..d5b564b0e5 100644 --- a/src/firefly/js/charts/ui/ChartsContainer.jsx +++ b/src/firefly/js/charts/ui/ChartsContainer.jsx @@ -7,9 +7,10 @@ import PropTypes from 'prop-types'; import {isEqual, isEmpty} from 'lodash'; import {LO_VIEW, LO_MODE, dispatchSetLayoutMode} from '../../core/LayoutCntlr.js'; -import {PLOT2D, DEFAULT_PLOT2D_VIEWER_ID, dispatchAddViewerItems, dispatchRemoveViewerItems, dispatchUpdateCustom, getViewerItemIds, getMultiViewRoot, dispatchChangeViewerLayout} from '../../visualize/MultiViewCntlr.js'; +import {dispatchAddViewerItems, dispatchRemoveViewerItems, dispatchUpdateCustom, getViewerItemIds, getMultiViewRoot, dispatchChangeViewerLayout} from '../../visualize/MultiViewCntlr.js'; import {monitorChanges, findGroupByTblId, getActiveTableId, isFullyLoaded, } from '../../tables/TableUtil.js'; import {TBL_RESULTS_ACTIVE, TABLE_LOADED, TABLE_SELECT} from '../../tables/TablesCntlr'; +import {DEFAULT_PLOT2D_VIEWER_ID, PLOT2D} from '../../visualize/VisConst'; import {CHART_ADD, CHART_REMOVE, getChartIdsInGroup, getChartData, dispatchChartAdd, getExpandedChartProps} from '../ChartsCntlr.js'; import {getDefaultChartProps, allowPinnedCharts} from '../ChartUtil.js'; diff --git a/src/firefly/js/charts/ui/CombineChart.jsx b/src/firefly/js/charts/ui/CombineChart.jsx index a25f7ec966..5083bc7349 100644 --- a/src/firefly/js/charts/ui/CombineChart.jsx +++ b/src/firefly/js/charts/ui/CombineChart.jsx @@ -5,7 +5,8 @@ import React, {useEffect, useState} from 'react'; import {cloneDeep, get, pick, set} from 'lodash'; -import {getMultiViewRoot, getViewerItemIds, PINNED_CHART_VIEWER_ID} from '../../visualize/MultiViewCntlr.js'; +import {getMultiViewRoot, getViewerItemIds} from '../../visualize/MultiViewCntlr.js'; +import {PINNED_CHART_VIEWER_ID} from '../../visualize/VisConst'; import {getSpectrumDM} from '../../voAnalyzer/SpectrumDM.js'; import {dispatchChartAdd, getChartData} from '../ChartsCntlr.js'; import {getNewTraceDefaults, getTblIdFromChart, isSpectralOrder, uniqueChartId} from '../ChartUtil.js'; diff --git a/src/firefly/js/charts/ui/MultiChartViewer.jsx b/src/firefly/js/charts/ui/MultiChartViewer.jsx index 1d10aa2cdf..48443c710f 100644 --- a/src/firefly/js/charts/ui/MultiChartViewer.jsx +++ b/src/firefly/js/charts/ui/MultiChartViewer.jsx @@ -9,10 +9,11 @@ import {isEmpty, isUndefined} from 'lodash'; import {flux} from '../../core/ReduxFlux.js'; import {CloseButton} from '../../ui/CloseButton.jsx'; +import {PLOT2D} from '../../visualize/VisConst'; import {ChartPanel} from './ChartPanel.jsx'; import {MultiItemViewerView} from '../../visualize/ui/MultiItemViewerView.jsx'; import {dispatchAddViewer, dispatchViewerUnmounted, dispatchUpdateCustom, - getMultiViewRoot, getViewer, getLayoutType, PLOT2D} from '../../visualize/MultiViewCntlr.js'; + getMultiViewRoot, getViewer, getLayoutType} from '../../visualize/MultiViewCntlr.js'; import {getExpandedChartProps, getChartData} from '../ChartsCntlr.js'; import {LO_VIEW, LO_MODE, dispatchSetLayoutMode} from '../../core/LayoutCntlr.js'; diff --git a/src/firefly/js/charts/ui/PinnedChartContainer.jsx b/src/firefly/js/charts/ui/PinnedChartContainer.jsx index 21952b4592..e3609cc009 100644 --- a/src/firefly/js/charts/ui/PinnedChartContainer.jsx +++ b/src/firefly/js/charts/ui/PinnedChartContainer.jsx @@ -12,10 +12,10 @@ import {CloseButton} from '../../ui/CloseButton.jsx'; import {ChartPanel} from './ChartPanel.jsx'; import {MultiItemViewerView} from '../../visualize/ui/MultiItemViewerView.jsx'; import { - dispatchAddViewer, dispatchViewerUnmounted, dispatchUpdateCustom, - getMultiViewRoot, getViewer, getLayoutType, PLOT2D, getViewerItemIds, dispatchRemoveViewerItems, - dispatchAddViewerItems, NewPlotMode, PINNED_CHART_VIEWER_ID + dispatchAddViewer, dispatchViewerUnmounted, dispatchUpdateCustom, getMultiViewRoot, getViewer, getLayoutType, + getViewerItemIds, dispatchRemoveViewerItems, dispatchAddViewerItems } from '../../visualize/MultiViewCntlr.js'; +import {NewPlotMode, PINNED_CHART_VIEWER_ID, PLOT2D} from '../../visualize/VisConst'; import { getExpandedChartProps, getChartData, CHART_ADD, CHART_REMOVE, getChartIdsInGroup, dispatchChartAdd, dispatchChartRemove, CHART_UPDATE } from '../ChartsCntlr.js'; diff --git a/src/firefly/js/charts/ui/PlotlyToolbar.jsx b/src/firefly/js/charts/ui/PlotlyToolbar.jsx index 324af01f23..7e4cf1dd76 100644 --- a/src/firefly/js/charts/ui/PlotlyToolbar.jsx +++ b/src/firefly/js/charts/ui/PlotlyToolbar.jsx @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import {IconButton, Stack, ToggleButtonGroup} from '@mui/joy'; import {get, isEmpty} from 'lodash'; import {ToolbarButton} from '../../ui/ToolbarButton.jsx'; +import {DEFAULT_PLOT2D_VIEWER_ID, PLOT2D} from '../../visualize/VisConst'; import {dispatchChartUpdate, dispatchChartFilterSelection, dispatchChartSelect, getChartData, dispatchSetActiveTrace, dispatchChartExpanded, resetChart} from '../ChartsCntlr.js'; import {useStoreConnector} from '../../ui/SimpleComponent.jsx'; @@ -17,9 +18,7 @@ import {showOptionsPopup} from '../../ui/PopupUtil.jsx'; import {CHART_ADDNEW, CHART_TRACE_MODIFY, showChartsDialog} from './ChartSelectPanel.jsx'; import {TableFilterPopup} from '../../tables/ui/FilterEditor'; import {getTblIdFromChart, isScatter2d} from '../ChartUtil.js'; -import { - DEFAULT_PLOT2D_VIEWER_ID, findViewerWithItemId, getLayoutType, getMultiViewRoot, PLOT2D -} from '../../visualize/MultiViewCntlr.js'; +import {findViewerWithItemId, getLayoutType, getMultiViewRoot} from '../../visualize/MultiViewCntlr.js'; import {ListBoxInputFieldView} from 'firefly/ui/ListBoxInputField'; import { AddItem, CheckedButton, CheckedClearButton, ClearFilterButton, ExpandButton, diff --git a/src/firefly/js/charts/ui/options/BasicOptions.jsx b/src/firefly/js/charts/ui/options/BasicOptions.jsx index 1d4a9c85c9..ed94ea05b4 100644 --- a/src/firefly/js/charts/ui/options/BasicOptions.jsx +++ b/src/firefly/js/charts/ui/options/BasicOptions.jsx @@ -1,6 +1,7 @@ import React, {useCallback, useEffect} from 'react'; import PropTypes from 'prop-types'; import {get, isArray, isEmpty, isString, isUndefined, memoize, reverse, set} from 'lodash'; +import {DEFAULT_PLOT2D_VIEWER_ID} from '../../../visualize/VisConst'; import {dispatchChartAdd, dispatchChartUpdate, getChartData} from '../../ChartsCntlr.js'; import {FieldGroup} from '../../../ui/FieldGroup.jsx'; @@ -23,7 +24,6 @@ import {hideColSelectPopup} from '../ColSelectView.jsx'; import {addColorbarChanges} from '../../dataTypes/FireflyHeatmap.js'; import {colorsOnTypes, getChartProps, toRGBA, TRACE_COLORS, uniqueChartId, isSpectrum} from '../../ChartUtil.js'; import {colorscaleNameToVal} from '../../Colorscale.js'; -import {DEFAULT_PLOT2D_VIEWER_ID} from '../../../visualize/MultiViewCntlr.js'; import MAGNIFYING_GLASS from 'html/images/icons-2014/magnifyingGlass.png'; import {ToolbarButton} from '../../../ui/ToolbarButton.jsx'; diff --git a/src/firefly/js/core/AppDataCntlr.js b/src/firefly/js/core/AppDataCntlr.js index d3b2a3092f..4af1814025 100644 --- a/src/firefly/js/core/AppDataCntlr.js +++ b/src/firefly/js/core/AppDataCntlr.js @@ -2,24 +2,23 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import {get, map, isUndefined, isEmpty} from 'lodash'; -import {flux} from './ReduxFlux'; -import {dispatchAddActionWatcher} from './MasterSaga'; -import {appDataReducer, menuReducer, alertsReducer} from './AppDataReducers.js'; -import Point, {isValidPoint} from '../visualize/Point.js'; +import {getLayouInfo} from 'firefly/core/LayoutCntlr'; +import {get, isEmpty, isUndefined, map} from 'lodash'; import {getModuleName, getProp, getRootURL, isFullURL} from '../util/WebUtil.js'; +import Point, {isValidPoint} from '../visualize/Point.js'; +import {alertsReducer, appDataReducer, menuReducer} from './AppDataReducers.js'; +import {makeBackgroundMonitorMenuItem} from './background/JobMonitor'; +import {APP_DATA_PATH} from './CoreConst'; import {dispatchRemoteAction} from './JsonUtils.js'; +import {dispatchAddActionWatcher} from './MasterSaga'; import {getWsConn} from './messaging/WebSocketClient'; -import {getLayouInfo} from 'firefly/core/LayoutCntlr'; -import {makeBackgroundMonitorMenuItem} from './background/JobMonitor'; +import {flux} from './ReduxFlux'; -export const APP_DATA_PATH = 'app_data'; export const COMMAND = 'COMMAND'; /*---------------------------- ACTIONS -----------------------------*/ export const APP_LOAD = `${APP_DATA_PATH}.appLoad`; -export const REINIT_APP= `${APP_DATA_PATH}.reinitApp`; export const APP_UPDATE = `${APP_DATA_PATH}.appUpdate`; export const ADD_WORKING_TASK = `${APP_DATA_PATH}.addWorkingTask`; export const REMOVE_WORKING_TASK = `${APP_DATA_PATH}.removeTaskCount`; diff --git a/src/firefly/js/core/ComponentCntlr.js b/src/firefly/js/core/ComponentCntlr.js index 6a7f097472..9d685cb6dc 100644 --- a/src/firefly/js/core/ComponentCntlr.js +++ b/src/firefly/js/core/ComponentCntlr.js @@ -5,7 +5,7 @@ import {flux} from './ReduxFlux'; import {get, isNil} from 'lodash'; import update from 'immutability-helper'; -import {REINIT_APP} from './AppDataCntlr.js'; +import {REINIT_APP} from './CoreConst'; export const DIALOG_OR_COMPONENT_KEY = 'dialogOrComponent'; diff --git a/src/firefly/js/core/CoreConst.js b/src/firefly/js/core/CoreConst.js new file mode 100644 index 0000000000..035fee8d47 --- /dev/null +++ b/src/firefly/js/core/CoreConst.js @@ -0,0 +1,14 @@ +/* + * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt + */ + +// + +// redux store object keys +export const APP_DATA_PATH = 'app_data'; + + +// ---------------------------------------- +// actions use by AppDataCntrl.js +// ---------------------------------------- +export const REINIT_APP = `${APP_DATA_PATH}.reinitApp`; \ No newline at end of file diff --git a/src/firefly/js/core/ExternalAccessCntlr.js b/src/firefly/js/core/ExternalAccessCntlr.js index ab792fd4e7..5f15d58bd0 100644 --- a/src/firefly/js/core/ExternalAccessCntlr.js +++ b/src/firefly/js/core/ExternalAccessCntlr.js @@ -4,7 +4,7 @@ import {flux} from './ReduxFlux'; import {doExtensionActivate} from './ExternalAccessUtils.js'; import {POINT} from './ExternalAccessUtils.js'; -import {dispatchChangePointSelection} from '../visualize/ImagePlotCntlr.js'; +import {dispatchChangePointSelection} from '../visualize/ImagePlotDispatch'; const EXTENSION_ADD= 'ExternalAccessCntlr/extensionAdd'; const EXTENSION_REMOVE= 'ExternalAccessCntlr/extensionRemove'; diff --git a/src/firefly/js/core/LayoutCntlr.js b/src/firefly/js/core/LayoutCntlr.js index 3cf07f4d14..314fe5b758 100644 --- a/src/firefly/js/core/LayoutCntlr.js +++ b/src/firefly/js/core/LayoutCntlr.js @@ -10,18 +10,18 @@ import {DATA_PRODUCT_ID_PREFIX, dataProductRoot} from '../metaConvert/DataProduc import {getBackgroundInfo, isMonitored, isSearchJob} from './background/BackgroundUtil.js'; import {flux} from './ReduxFlux'; import {clone} from '../util/WebUtil.js'; +import { smartMerge, getActiveTableId, getTblById, findGroupByTblId, getTblIdsByGroup, } from '../tables/TableUtil.js'; import { - smartMerge, getActiveTableId, getTblById, findGroupByTblId, getTblIdsByGroup, -} from '../tables/TableUtil.js'; -import ImagePlotCntlr, {visRoot} from '../visualize/ImagePlotCntlr.js'; + DEFAULT_FITS_VIEWER_ID, + DEFAULT_PLOT2D_VIEWER_ID, PINNED_CHART_VIEWER_ID, PLOT_IMAGE, PLOT_IMAGE_START, REPLACE_VIEWER_ITEMS +} from '../visualize/VisConst'; +import {visRoot} from '../visualize/VisStoreRoots'; import { TBL_RESULTS_ADDED, TBL_RESULTS_REMOVE, TABLE_REMOVE, TABLE_SPACE_PATH, TBL_RESULTS_ACTIVE, TABLE_LOADED } from '../tables/TablesCntlr.js'; import {CHART_ADD, CHART_REMOVE, CHART_SPACE_PATH} from '../charts/ChartsCntlr.js'; -import { - DEFAULT_FITS_VIEWER_ID, - DEFAULT_PLOT2D_VIEWER_ID, getMultiViewRoot, getViewer, PINNED_CHART_VIEWER_ID, REPLACE_VIEWER_ITEMS -} from '../visualize/MultiViewCntlr.js'; -import {COMMAND, getMenu, REINIT_APP} from './AppDataCntlr.js'; +import { getMultiViewRoot, getViewer } from '../visualize/MultiViewCntlr.js'; +import {REINIT_APP} from './CoreConst'; +import {COMMAND, getMenu} from './AppDataCntlr.js'; import {getDefaultChartProps} from '../charts/ChartUtil.js'; import {getPlotViewAry, getPlotViewById} from 'firefly/visualize/PlotViewUtil.js'; import {MetaConst} from 'firefly/data/MetaConst'; @@ -457,9 +457,9 @@ export function dropDownHandler(layoutInfo, action) { } return smartMerge(layoutInfo, {dropDown: resultsViewDropdown}); case REPLACE_VIEWER_ITEMS : - case ImagePlotCntlr.PLOT_IMAGE : + case PLOT_IMAGE : return smartMerge(layoutInfo, {dropDown: resultsViewDropdown}); - case ImagePlotCntlr.PLOT_IMAGE_START : + case PLOT_IMAGE_START : const VISUALIZED_TABLE_IDS = action.payload?.attributes?.VISUALIZED_TABLE_IDS; if (VISUALIZED_TABLE_IDS?.length) { const lastId = VISUALIZED_TABLE_IDS[VISUALIZED_TABLE_IDS.length - 1]; @@ -484,7 +484,7 @@ export function dropDownHandler(layoutInfo, action) { export function* dropDownManager() { while (true) { const action = yield take([ - ImagePlotCntlr.PLOT_IMAGE_START, ImagePlotCntlr.PLOT_IMAGE, + PLOT_IMAGE_START, PLOT_IMAGE, REPLACE_VIEWER_ITEMS, TABLE_REMOVE, TBL_RESULTS_ADDED, TBL_RESULTS_REMOVE, CHART_ADD, CHART_REMOVE, diff --git a/src/firefly/js/core/background/BackgroundUtil.js b/src/firefly/js/core/background/BackgroundUtil.js index 9c9b327b7f..21085821c2 100644 --- a/src/firefly/js/core/background/BackgroundUtil.js +++ b/src/firefly/js/core/background/BackgroundUtil.js @@ -20,8 +20,9 @@ import * as TblUtil from 'firefly/tables/TableUtil'; import {copyRequestOptions, getRequestFromJob, getTblId, makeFileRequest} from 'firefly/tables/TableRequestUtil'; import {dispatchTableRemove, dispatchTableSearch, dispatchTableUpdate} from 'firefly/tables/TablesCntlr'; import WebPlotRequest, {TitleOptions} from 'firefly/visualize/WebPlotRequest'; -import {getAViewFromMultiView, getMultiViewRoot, IMAGE} from 'firefly/visualize/MultiViewCntlr'; -import {dispatchPlotImage} from 'firefly/visualize/ImagePlotCntlr'; +import {getAViewFromMultiView, getMultiViewRoot} from 'firefly/visualize/MultiViewCntlr'; +import {dispatchPlotImage} from '../../visualize/ImagePlotDispatch'; +import {IMAGE} from '../../visualize/VisConst'; import {dispatchFormSubmit} from 'firefly/core/AppDataCntlr'; import {showJobMonitor, showMultiMultiResults} from 'firefly/core/background/JobMonitor'; import {getTableUiByTblId} from 'firefly/tables/TableUtil'; diff --git a/src/firefly/js/drawingLayers/Artifact.js b/src/firefly/js/drawingLayers/Artifact.js index 1120246f72..c810fbd41b 100644 --- a/src/firefly/js/drawingLayers/Artifact.js +++ b/src/firefly/js/drawingLayers/Artifact.js @@ -4,18 +4,21 @@ import {get, isEmpty} from 'lodash'; +import {dispatchModifyCustomField} from '../visualize/DrawLayerDispatch'; +import {dlRoot} from '../visualize/VisStoreRoots'; import {findTableCenterColumns} from '../voAnalyzer/TableAnalysis.js'; -import {isPlotIdInPvNewPlotInfoAry, - isDrawLayerVisible, getDrawLayerById, getPlotViewById} from '../visualize/PlotViewUtil.js'; +import { isPlotIdInPvNewPlotInfoAry, isDrawLayerVisible, getDrawLayerById, currentP} from '../visualize/PlotViewUtil.js'; import {getRelatedDataById} from '../visualize/RelatedDataUtil.js'; import {clone} from '../util/WebUtil.js'; -import ImagePlotCntlr, {visRoot} from '../visualize/ImagePlotCntlr.js'; +import { + ATTACH_LAYER_TO_PLOT, CHANGE_VISIBILITY, DELETE_PLOT_VIEW, DESTROY_DRAWING_LAYER, MODIFY_CUSTOM_FIELD, PLOT_IMAGE, + PLOT_IMAGE_FAIL +} from '../visualize/VisConst'; import PointDataObj from '../visualize/draw/PointDataObj.js'; import {DrawSymbol} from '../visualize/draw/DrawSymbol.js'; import {makeDrawingDef, getNextColor} from '../visualize/draw/DrawingDef.js'; import DrawLayer, {ColorChangeType} from '../visualize/draw/DrawLayer.js'; import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js'; -import DrawLayerCntlr, {dlRoot, dispatchModifyCustomField} from '../visualize/DrawLayerCntlr.js'; import {makeWorldPt} from '../visualize/Point.js'; import {doFetchTable} from '../tables/TableUtil.js'; import {getUIComponent} from './CatalogUI.jsx'; @@ -44,18 +47,18 @@ function watchReplot(action, cancelSelf, params) { const {payload}= action; const {plotId, drawLayerId}= params; switch (action.type) { - case ImagePlotCntlr.PLOT_IMAGE: + case PLOT_IMAGE: if (isPlotIdInPvNewPlotInfoAry(payload.pvNewPlotInfoAry, plotId)) { updateArtifactTable(plotId, drawLayerId); } break; - case ImagePlotCntlr.PLOT_IMAGE_FAIL: + case PLOT_IMAGE_FAIL: payload.plotId===plotId && dispatchModifyCustomField(drawLayerId, {tableModel:null}); break; - case ImagePlotCntlr.DELETE_PLOT_VIEW: + case DELETE_PLOT_VIEW: payload.plotId===plotId && cancelSelf(); break; - case DrawLayerCntlr.DESTROY_DRAWING_LAYER: + case DESTROY_DRAWING_LAYER: payload.drawLayerId===drawLayerId && cancelSelf(); break; } @@ -67,7 +70,7 @@ function watchReplot(action, cancelSelf, params) { function updateArtifactTable(plotId, drawLayerId) { const dl= getDrawLayerById(dlRoot(), drawLayerId); - const pv= getPlotViewById(visRoot(), plotId); + const {pv}= currentP(plotId); if (!dl || !pv) return; if (isDrawLayerVisible(dl,plotId)) { retrieveArtifactsTable(dl); @@ -80,7 +83,7 @@ function updateArtifactTable(plotId, drawLayerId) { function retrieveArtifactsTable(drawLayer) { - const pv= getPlotViewById(visRoot(), drawLayer.plotId); + const {pv}= currentP(drawLayer.plotId); const rd= getRelatedDataById(pv, drawLayer.relatedDataId); if (!rd) return; @@ -113,7 +116,7 @@ function retrieveArtifactsTable(drawLayer) { function creator(initPayload, presetDefaults) { const {title, color, angleInRadian=false, relatedDataId, plotId, symbol, size, layersPanelLayoutId}= initPayload; - const pv= getPlotViewById(visRoot(), plotId); + const {pv}= currentP(plotId); const rd= getRelatedDataById(pv, relatedDataId); const dataKey= get(rd, 'dataKey'); @@ -148,8 +151,7 @@ function creator(initPayload, presetDefaults) { dispatchAddActionWatcher({ callback:watchReplot, params:{drawLayerId:dl.drawLayerId, plotId}, - actions:[ImagePlotCntlr.PLOT_IMAGE, ImagePlotCntlr.PLOT_IMAGE_FAIL, - ImagePlotCntlr.DELETE_PLOT_VIEW, DrawLayerCntlr.DESTROY_DRAWING_LAYER] + actions:[PLOT_IMAGE, PLOT_IMAGE_FAIL, DELETE_PLOT_VIEW, DESTROY_DRAWING_LAYER] }); return dl; @@ -159,14 +161,14 @@ function creator(initPayload, presetDefaults) { function getLayerChanges(drawLayer, action) { switch (action.type) { - case DrawLayerCntlr.MODIFY_CUSTOM_FIELD: + case MODIFY_CUSTOM_FIELD: const {tableModel}= action.payload.changes; return tableModel ? Object.assign({tableModel}, createDrawData(drawLayer, tableModel)) : {tableModel:null, drawData: null}; break; - case DrawLayerCntlr.ATTACH_LAYER_TO_PLOT: - case DrawLayerCntlr.CHANGE_VISIBILITY: + case ATTACH_LAYER_TO_PLOT: + case CHANGE_VISIBILITY: if (action.payload.visible && !drawLayer.tableModel) { retrieveArtifactsTable(drawLayer); //start the server retrieve call } diff --git a/src/firefly/js/drawingLayers/Catalog.js b/src/firefly/js/drawingLayers/Catalog.js index 19387043b7..b82a54af77 100644 --- a/src/firefly/js/drawingLayers/Catalog.js +++ b/src/firefly/js/drawingLayers/Catalog.js @@ -6,16 +6,17 @@ import {isEmpty,isArray} from 'lodash'; import Enum from 'enum'; import {makeTableColorTitle} from '../visualize/ui/DrawLayerUIComponents'; +import {MODIFY_CUSTOM_FIELD, SUBGROUP} from '../visualize/VisConst'; import {getSelectedPts} from '../visualize/WebPlotAnalysis'; -import {primePlot, getAllDrawLayersForPlot, getCenterOfProjection} from '../visualize/PlotViewUtil.js'; -import {visRoot, dispatchUseTableAutoScroll} from '../visualize/ImagePlotCntlr.js'; +import {primePlot, getAllDrawLayersForPlot, getCenterOfProjection, currentP} from '../visualize/PlotViewUtil.js'; +import {dispatchUseTableAutoScroll} from '../visualize/ImagePlotDispatch'; +import {dlRoot, visRoot} from '../visualize/VisStoreRoots'; import PointDataObj from '../visualize/draw/PointDataObj.js'; import {DrawSymbol} from '../visualize/draw/DrawSymbol.js'; import FootprintObj from '../visualize/draw/FootprintObj.js'; import {makeDrawingDef, getNextColor} from '../visualize/draw/DrawingDef.js'; import DrawLayer, {DataTypes,ColorChangeType} from '../visualize/draw/DrawLayer.js'; import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js'; -import DrawLayerCntlr, {dlRoot, SUBGROUP} from '../visualize/DrawLayerCntlr.js'; import {MouseState} from '../visualize/VisMouseSync.js'; import DrawOp from '../visualize/draw/DrawOp.js'; import {makeImagePt, makeWorldPt, pointEquals} from '../visualize/Point.js'; @@ -151,13 +152,11 @@ function creator(initPayload, presetDefaults={}) { } // eslint-disable-next-line no-unused-vars -function layerRemoved(drawLayer,action) { -} +function layerRemoved(drawLayer,action) { } function saveLastDown(mouseStatePayload) { const {plotId}= mouseStatePayload; - const plot= primePlot(visRoot(),plotId); - lastProjectionCenter= {center:getCenterOfProjection(plot), plotId}; + lastProjectionCenter= {center:getCenterOfProjection(currentP(plotId).plot), plotId}; } /** @@ -167,8 +166,7 @@ function saveLastDown(mouseStatePayload) { function highlightChange(mouseStatePayload) { const {drawLayer,plotId,screenPt,shiftDown}= mouseStatePayload; if (shiftDown) return; - const plot= primePlot(visRoot(),plotId); - const center= getCenterOfProjection(plot); + const center= getCenterOfProjection(currentP(plotId).plot); if (lastProjectionCenter && (!pointEquals(center, lastProjectionCenter?.center) || lastProjectionCenter.plotId!==plotId)) return; lastProjectionCenter= undefined; makeHighlightDeferred(drawLayer,plotId,screenPt); @@ -191,7 +189,6 @@ function makeHighlightDeferred(drawLayer,plotId,screenPt) { let {data} = drawLayer.drawData; const {tableRequest} = drawLayer; let closestIdx = -1; - const plot = primePlot(visRoot(), plotId); if (drawLayer.catalogType===CatalogType.ORBITAL_PATH) { if (tableRequest.sortInfo || getNumFilters(tableRequest)) return () => undefined; @@ -223,7 +220,7 @@ function makeHighlightDeferred(drawLayer,plotId,screenPt) { let dist; - const cc= CysConverter.make(plot); + const cc= CysConverter.make(currentP(plotId).plot); for(let i=0;(idx dl.canSelect && dl.dataTooBigForSelection); if (tooBig) { - showInfoPopup('Your data set is too large to select. You must filter it down first.', `Can't Select`); + showInfoPopup('Your data set is too large to select. You must filter it down first.', `Can't Select`); // eslint-disable-line @stylistic/js/quotes } else { catDlAry.forEach( (dl) => { diff --git a/src/firefly/js/drawingLayers/CatalogUI.jsx b/src/firefly/js/drawingLayers/CatalogUI.jsx index 418ef2a85c..024f552f89 100644 --- a/src/firefly/js/drawingLayers/CatalogUI.jsx +++ b/src/firefly/js/drawingLayers/CatalogUI.jsx @@ -19,12 +19,13 @@ import {INFO_POPUP, showInfoPopup} from '../ui/PopupUtil.jsx'; import {RadioGroupInputFieldView} from '../ui/RadioGroupInputFieldView.jsx'; import {useStoreConnector} from '../ui/SimpleComponent'; import {DataTypes} from '../visualize/draw/DrawLayer.js'; -import {dispatchChangeVisibility, dispatchModifyCustomField, GroupingScope} from '../visualize/DrawLayerCntlr.js'; +import {dispatchChangeVisibility, dispatchModifyCustomField} from '../visualize/DrawLayerDispatch'; import {dispatchBottomUIComponent} from '../visualize/MultiViewCntlr'; import {isDrawLayerVisible} from '../visualize/PlotViewUtil.js'; import {InfoButton} from '../visualize/ui/Buttons.jsx'; import PriorityHighRoundedIcon from '@mui/icons-material/PriorityHighRounded'; +import {GroupingScope} from '../visualize/VisConst'; import { BOX_GROUP_TYPE, ELLIPSE_GROUP_TYPE, HEALPIX_GROUP_TYPE, HEAT_MAP_GROUP_TYPE, HPX_GRID_SIZE_LARGE, HPX_GRID_SIZE_PREF, HPX_GRID_SIZE_SMALL, HPX_GROUP_TYPE_PREF, HPX_HEATMAP_LABEL_PREF, HPX_HEATMAP_STRETCH_PREF, diff --git a/src/firefly/js/drawingLayers/DistanceTool.js b/src/firefly/js/drawingLayers/DistanceTool.js index 3cc2b26032..960ad1ffdd 100644 --- a/src/firefly/js/drawingLayers/DistanceTool.js +++ b/src/firefly/js/drawingLayers/DistanceTool.js @@ -2,19 +2,21 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import {isBoolean, isEmpty, isUndefined} from 'lodash'; -import DrawLayerCntlr, {DRAWING_LAYER_KEY} from '../visualize/DrawLayerCntlr.js'; +import {isBoolean, isEmpty} from 'lodash'; import {getPreference} from '../core/AppDataCntlr.js'; -import {visRoot,dispatchAttributeChange} from '../visualize/ImagePlotCntlr.js'; +import {dispatchAttributeChange} from '../visualize/ImagePlotDispatch'; import {makeDrawingDef,Style, TextLocation} from '../visualize/draw/DrawingDef.js'; import DrawLayer, {ColorChangeType} from '../visualize/draw/DrawLayer.js'; +import { + ATTACH_LAYER_TO_PLOT, DRAWING_LAYER_KEY, DT_END, DT_MOVE, DT_START, FORCE_DRAW_LAYER_UPDATE, MODIFY_CUSTOM_FIELD +} from '../visualize/VisConst'; import {MouseState} from '../visualize/VisMouseSync.js'; import {PlotAttribute} from '../visualize/PlotAttribute.js'; import CsysConverter from '../visualize/CsysConverter.js'; import { makeOffsetPt, makeWorldPt} from '../visualize/Point.js'; import BrowserInfo from '../util/BrowserInfo.js'; import ShapeDataObj from '../visualize/draw/ShapeDataObj.js'; -import {primePlot, getDrawLayerById} from '../visualize/PlotViewUtil.js'; +import {primePlot, getDrawLayerById, currentP} from '../visualize/PlotViewUtil.js'; import {computeDistance, computeScreenDistance, getPositionAngle} from '../visualize/VisUtil'; import {getUIComponent} from './DistanceToolUI.jsx'; import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js'; @@ -59,10 +61,9 @@ var idCnt=0; export function distanceToolEndActionCreator(rawAction) { return (dispatcher, getState) => { var {drawLayer, plotId}= rawAction.payload; - dispatcher({type:DrawLayerCntlr.DT_END, payload:rawAction.payload} ); + dispatcher({type:DT_END, payload:rawAction.payload} ); drawLayer= getDrawLayerById(getState()[DRAWING_LAYER_KEY], drawLayer.drawLayerId); - const srcPlot= primePlot(visRoot(),plotId); - const cc= CsysConverter.make(srcPlot); + const cc= CsysConverter.make(currentP(plotId).plot); const srcWorld = hasWCSProjection(cc); var sel= {pt0:drawLayer.firstPt,pt1:drawLayer.currentPt}; @@ -74,7 +75,7 @@ export function distanceToolEndActionCreator(rawAction) { }); } else { - const p= primePlot(visRoot(),pId); + const {plot:p}= currentP(pId); if (srcWorld && hasWCSProjection(p)) { const targetCC= CsysConverter.make(p); const pt0= targetCC.getImageCoords(cc.getWorldCoords(drawLayer.firstPt)); @@ -103,17 +104,15 @@ function creator() { const drawingDef= makeDrawingDef('red'); const pairs= { - [MouseState.DRAG.key]: DrawLayerCntlr.DT_MOVE, - [MouseState.DOWN.key]: DrawLayerCntlr.DT_START, - [MouseState.UP.key]: DrawLayerCntlr.DT_END + [MouseState.DRAG.key]: DT_MOVE, + [MouseState.DOWN.key]: DT_START, + [MouseState.UP.key]: DT_END }; const exclusiveDef= { exclusiveOnDown: true, type : 'anywhere' }; - const actionTypes= [DrawLayerCntlr.DT_START, - DrawLayerCntlr.DT_MOVE, - DrawLayerCntlr.DT_END]; + const actionTypes= [DT_START, DT_MOVE, DT_END]; idCnt++; const options= { @@ -128,7 +127,7 @@ function creator() { function onDetach(drawLayer,action) { const {plotIdAry}= action.payload; plotIdAry.forEach( (plotId) => { - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); if (plot && plot.attributes[PlotAttribute.ACTIVE_DISTANCE]) { dispatchAttributeChange({ plotId,overlayColorScope:false, @@ -154,20 +153,20 @@ function getCursor(plotView, screenPt) { function getLayerChanges(drawLayer, action) { switch (action.type) { - case DrawLayerCntlr.DT_START: + case DT_START: return start(drawLayer, action); - case DrawLayerCntlr.DT_MOVE: + case DT_MOVE: return drag(drawLayer,action); - case DrawLayerCntlr.DT_END: + case DT_END: return end(action); - case DrawLayerCntlr.ATTACH_LAYER_TO_PLOT: + case ATTACH_LAYER_TO_PLOT: if (isEmpty(drawLayer?.drawData?.data)) { return attach(); } break; - case DrawLayerCntlr.MODIFY_CUSTOM_FIELD: + case MODIFY_CUSTOM_FIELD: return dealWithMods(drawLayer,action); - case DrawLayerCntlr.FORCE_DRAW_LAYER_UPDATE: + case FORCE_DRAW_LAYER_UPDATE: return dealWithUnits(drawLayer,action); } @@ -196,7 +195,7 @@ function makeBaseReturnObj(plot,firstPt,currPt,drawAry ) { function dealWithUnits(drawLayer,action) { const {plotIdAry}= action.payload; - const plot= primePlot(visRoot(),plotIdAry[0]); + const {plot}= currentP(plotIdAry[0]); const cc= CsysConverter.make(plot); if (!cc || !plot) return null; @@ -212,7 +211,7 @@ function dealWithUnits(drawLayer,action) { function dealWithMods(drawLayer,action) { const {changes,plotIdAry}= action.payload; if (isBoolean(changes.offsetCal)) { - const plot= primePlot(visRoot(),plotIdAry[0]); + const {plot}= currentP(plotIdAry[0]); const cc= CsysConverter.make(plot); if (!cc) return null; const selection = plot.attributes[PlotAttribute.ACTIVE_DISTANCE]; @@ -231,7 +230,7 @@ export function getUnitStyle(cc, world) { if (!cc || !world) { return UNIT_PIXEL_ONLY; } else { - return isHiPS(primePlot(visRoot(),cc.plotId)) ? UNIT_NO_PIXEL : UNIT_ALL; + return isHiPS(currentP(cc.plotId).plot) ? UNIT_NO_PIXEL : UNIT_ALL; } } @@ -267,7 +266,7 @@ function getMode(plot) { function start(drawLayer, action) { const {imagePt,plotId,shiftDown}= action.payload; - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); const mode= getMode(plot); if (!plot) return; let retObj= {}; @@ -304,7 +303,7 @@ function start(drawLayer, action) { function drag(drawLayer,action) { const {imagePt,plotId}= action.payload; - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); const cc= CsysConverter.make(plot); const newFirst = drawLayer.moveHead ? drawLayer.firstPt : imagePt; @@ -316,7 +315,7 @@ function drag(drawLayer,action) { function end(action) { const {plotId}= action.payload; - const mode= getMode(primePlot(visRoot(),plotId)); + const mode= getMode(currentP(plotId).plot); const retObj= {}; if (mode==='select') { retObj.helpLine= editHelpText; @@ -494,7 +493,7 @@ function makeSelectObj(firstPt,currentPt, offsetCal, cc) { let lon1, lon2; let lat1, lat2; - const plot= primePlot(visRoot(),cc.plotId); + const {plot}= currentP(cc.plotId); const aHiPS = isHiPS(plot); let corner_pt; diff --git a/src/firefly/js/drawingLayers/DistanceToolUI.jsx b/src/firefly/js/drawingLayers/DistanceToolUI.jsx index 895a24c597..b7ac3fe4e7 100644 --- a/src/firefly/js/drawingLayers/DistanceToolUI.jsx +++ b/src/firefly/js/drawingLayers/DistanceToolUI.jsx @@ -6,8 +6,8 @@ import {Checkbox, Stack, Typography} from '@mui/joy'; import React from 'react'; import PropTypes from 'prop-types'; import {RadioGroupInputFieldView} from '../ui/RadioGroupInputFieldView.jsx'; -import {dispatchModifyCustomField, dispatchForceDrawLayerUpdate} from '../visualize/DrawLayerCntlr.js'; import * as AppDataCntlr from '../core/AppDataCntlr.js'; +import {dispatchForceDrawLayerUpdate, dispatchModifyCustomField} from '../visualize/DrawLayerDispatch'; import {DIST_READOUT, getUnitPreference, getUnitStyle, UNIT_NO_PIXEL, UNIT_ALL} from './DistanceTool.js'; import {hasWCSProjection} from '../visualize/PlotViewUtil'; import CsysConverter from '../visualize/CsysConverter'; diff --git a/src/firefly/js/drawingLayers/ExtractLineTool.js b/src/firefly/js/drawingLayers/ExtractLineTool.js index 70e45f5f38..864a2e17d3 100644 --- a/src/firefly/js/drawingLayers/ExtractLineTool.js +++ b/src/firefly/js/drawingLayers/ExtractLineTool.js @@ -2,22 +2,25 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import DrawLayerCntlr, {DRAWING_LAYER_KEY, getDlAry} from '../visualize/DrawLayerCntlr.js'; -import {visRoot,dispatchAttributeChange} from '../visualize/ImagePlotCntlr.js'; +import {dispatchAttributeChange} from '../visualize/ImagePlotDispatch'; import {makeDrawingDef,Style, TextLocation} from '../visualize/draw/DrawingDef.js'; import DrawLayer, {ColorChangeType} from '../visualize/draw/DrawLayer.js'; import {makeImagePt} from '../visualize/Point'; +import { + ATTACH_LAYER_TO_PLOT, DRAWING_LAYER_KEY, ELT_END, ELT_MOVE, ELT_START, MODIFY_CUSTOM_FIELD +} from '../visualize/VisConst'; import {MouseState} from '../visualize/VisMouseSync.js'; import {PlotAttribute} from '../visualize/PlotAttribute.js'; import CsysConverter from '../visualize/CsysConverter.js'; import BrowserInfo from '../util/BrowserInfo.js'; import ShapeDataObj from '../visualize/draw/ShapeDataObj.js'; import PointDataObj from '../visualize/draw/PointDataObj.js'; -import {primePlot, getDrawLayerById} from '../visualize/PlotViewUtil.js'; +import {primePlot, getDrawLayerById, currentP} from '../visualize/PlotViewUtil.js'; import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js'; import {hasWCSProjection} from '../visualize/PlotViewUtil'; import {DrawingType} from '../visualize/draw/DrawObj'; import {DrawSymbol} from 'firefly/visualize/draw/DrawSymbol.js'; +import {getDlAry} from '../visualize/VisStoreRoots'; import {computeScreenDistance} from '../visualize/VisUtil'; @@ -43,7 +46,7 @@ let idCnt=1; export function extractLineToolStartActionCreator(rawAction) { return (dispatcher, getState) => { const {plotId} = rawAction.payload; - dispatcher({type: DrawLayerCntlr.ELT_START, payload: rawAction.payload}); + dispatcher({type: ELT_START, payload: rawAction.payload}); dispatchAttributeChange({ plotId, overlayColorScope: true, changes: {[PlotAttribute.SELECT_ACTIVE_CHART_PT]: undefined} @@ -60,7 +63,7 @@ function addLineDistAttributesToPlotsLater(drawLayerId, plotId, sel) { } export function addLineDistAttributesToPlots(drawLayer, plotId, sel) { - const srcPlot= primePlot(visRoot(),plotId); + const srcPlot= currentP(plotId).plot; const cc= CsysConverter.make(srcPlot); const srcWorld = hasWCSProjection(cc); drawLayer.plotIdAry.forEach( @@ -71,7 +74,7 @@ export function addLineDistAttributesToPlots(drawLayer, plotId, sel) { }); } else { - const p= primePlot(visRoot(),pId); + const {plot:p}= currentP(pId); if (srcWorld && hasWCSProjection(p)) { const targetCC= CsysConverter.make(p); const pt0= targetCC.getImageCoords(cc.getWorldCoords(drawLayer.firstPt)); @@ -92,7 +95,7 @@ export function extractLineToolEndActionCreator(rawAction) { return (dispatcher, getState) => { let {drawLayer}= rawAction.payload; const {plotId}= rawAction.payload; - dispatcher({type:DrawLayerCntlr.DT_END, payload:rawAction.payload} ); + dispatcher({type:ELT_END, payload:rawAction.payload} ); drawLayer= getDrawLayerById(getState()[DRAWING_LAYER_KEY], drawLayer.drawLayerId); // make sure it is the most recent version const sel= {pt0:drawLayer.firstPt,pt1:drawLayer.currentPt}; if (sel.pt0===sel.pt1) return; @@ -106,12 +109,12 @@ export function extractLineToolEndActionCreator(rawAction) { */ function creator() { const pairs= { - [MouseState.DRAG.key]: DrawLayerCntlr.ELT_MOVE, - [MouseState.DOWN.key]: DrawLayerCntlr.ELT_START, - [MouseState.UP.key]: DrawLayerCntlr.ELT_END + [MouseState.DRAG.key]: ELT_MOVE, + [MouseState.DOWN.key]: ELT_START, + [MouseState.UP.key]: ELT_END }; const exclusiveDef= { exclusiveOnDown: true, type : 'anywhere' }; - const actionTypes= [DrawLayerCntlr.ELT_START, DrawLayerCntlr.ELT_MOVE, DrawLayerCntlr.ELT_END]; + const actionTypes= [ELT_START, ELT_MOVE, ELT_END]; const options= { canUseMouse:true, @@ -131,7 +134,7 @@ function creator() { function onDetach(drawLayer,action) { const {plotIdAry}= action.payload; plotIdAry?.forEach( (plotId) => { - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); if (plot && plot.attributes[PlotAttribute.ACTIVE_DISTANCE]) { dispatchAttributeChange({ plotId,overlayColorScope:false, @@ -155,16 +158,11 @@ function getCursor(plotView, screenPt) { function getLayerChanges(drawLayer, action) { switch (action.type) { - case DrawLayerCntlr.ELT_START: - return start(drawLayer, action); - case DrawLayerCntlr.ELT_MOVE: - return drag(drawLayer,action); - case DrawLayerCntlr.ELT_END: - return end(action); - case DrawLayerCntlr.ATTACH_LAYER_TO_PLOT: - return attach(drawLayer); - case DrawLayerCntlr.MODIFY_CUSTOM_FIELD: - return dealWithMods(drawLayer,action); + case ELT_START: return start(drawLayer, action); + case ELT_MOVE: return drag(drawLayer,action); + case ELT_END: return end(action); + case ATTACH_LAYER_TO_PLOT: return attach(drawLayer); + case MODIFY_CUSTOM_FIELD: return dealWithMods(drawLayer,action); } } @@ -187,8 +185,8 @@ function makeBaseReturnObj(firstPt,currPt,drawAry ) { function dealWithMods(drawLayer,action) { const {changes,plotIdAry}= action.payload; if (Object.keys(changes).includes('activePt') || Object.keys(changes).includes('selectionType')) { - let plot= primePlot(visRoot()); - if (!plotIdAry.includes(plot.plotId)) plot= primePlot(visRoot(),plotIdAry[0]); + let {plot}= currentP(); + if (!plotIdAry.includes(plot.plotId)) plot= currentP(plotIdAry[0]).plot; const cc= CsysConverter.make(plot); if (!cc) return null; const {activePt=drawLayer.activePoint, selectionType=drawLayer.selectionType}= changes; @@ -218,7 +216,7 @@ function dealWithMods(drawLayer,action) { else if (Object.keys(changes).includes('newFirst') || Object.keys(changes).includes('newCurrent') ){ const {newFirst,newCurrent, newSelectionType=drawLayer.selectionType}= changes; if (!changes.plotId) return; - const plot= primePlot(visRoot(),changes.plotId); + const {plot}= currentP(changes.plotId); const cc= CsysConverter.make(plot); if (!newFirst) { return makeBaseReturnObj(newFirst, newCurrent,[]); @@ -250,7 +248,7 @@ function start(drawLayer, action) { const newDl= {...drawLayer, ...setupSelect(plotId,imagePt,drawLayer)}; return drag(newDl, action); } - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); const mode= getMode(plot); if (!plot || shiftDown) return; const cc= CsysConverter.make(plot); @@ -295,7 +293,7 @@ function start(drawLayer, action) { function drag(drawLayer,action) { const {imagePt,plotId, shiftDown}= action.payload; - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); const cc= CsysConverter.make(plot); if (!cc || shiftDown) return; const {dataWidth,dataHeight}= plot; @@ -323,7 +321,7 @@ function drag(drawLayer,action) { function end(action) { const {plotId, shiftDown}= action.payload; if (shiftDown) return; - const mode= getMode(primePlot(visRoot(),plotId)); + const mode= getMode(currentP(plotId).plot); const retObj= {startSelectCnt:0}; if (mode==='select') { retObj.helpLine= editHelpText; @@ -401,12 +399,10 @@ function makeSelectObj(firstPt,currentPt, activePt, selectionType, offsetCal, cc function getPtAry(plot) { const sel= plot.attributes[PlotAttribute.ACTIVE_DISTANCE]; - if (!sel) return null; + if (!sel) return; const cc = CsysConverter.make(plot); - const ptAry=[]; - ptAry[0]= cc.getScreenCoords(sel.pt0); - ptAry[1]= cc.getScreenCoords(sel.pt1); + const ptAry=[ cc.getScreenCoords(sel.pt0), cc.getScreenCoords(sel.pt1)]; if (!ptAry[0] || !ptAry[1]) return null; return ptAry; } diff --git a/src/firefly/js/drawingLayers/ExtractPointsTool.js b/src/firefly/js/drawingLayers/ExtractPointsTool.js index 939f41a8f4..c96e14a8bb 100644 --- a/src/firefly/js/drawingLayers/ExtractPointsTool.js +++ b/src/firefly/js/drawingLayers/ExtractPointsTool.js @@ -3,9 +3,12 @@ */ -import DrawLayerCntlr, {dispatchForceDrawLayerUpdate} from '../visualize/DrawLayerCntlr.js'; -import {visRoot,dispatchAttributeChange} from '../visualize/ImagePlotCntlr.js'; -import {primePlot, isActivePlotView} from '../visualize/PlotViewUtil.js'; +import {dispatchForceDrawLayerUpdate} from '../visualize/DrawLayerDispatch'; +import { + ATTACH_LAYER_TO_PLOT, CHANGE_DRAWING_DEF, EXTRACT_POINT, FORCE_DRAW_LAYER_UPDATE, MODIFY_CUSTOM_FIELD, SELECT_POINT +} from '../visualize/VisConst'; +import {dispatchAttributeChange} from '../visualize/ImagePlotDispatch'; +import {currentP} from '../visualize/PlotViewUtil.js'; import {PlotAttribute} from '../visualize/PlotAttribute.js'; import PointDataObj from '../visualize/draw/PointDataObj.js'; import {DrawSymbol} from '../visualize/draw/DrawSymbol.js'; @@ -34,7 +37,7 @@ function dispatchSelectPoint(mouseStatePayload) { const {plotId,screenPt,drawLayer,shiftDown}= mouseStatePayload; if (shiftDown) return; if (drawLayer.drawData.data) { - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); const ptAry= plot.attributes[PlotAttribute.PT_ARY] ?? []; const cc= CsysConverter.make(plot); const newPtAry= ptAry.filter( (pt) => cc.pointInPlot(pt)); @@ -42,7 +45,7 @@ function dispatchSelectPoint(mouseStatePayload) { if (newPt) newPtAry.push(newPt); dispatchAttributeChange( {plotId, changes:{[PlotAttribute.PT_ARY]:newPtAry} }); - flux.process({type:DrawLayerCntlr.EXTRACT_POINT, payload:mouseStatePayload} ); + flux.process({type:EXTRACT_POINT, payload:mouseStatePayload} ); dispatchForceDrawLayerUpdate(drawLayer.drawLayerId, plotId); } } @@ -51,7 +54,7 @@ function dispatchSelectPoint(mouseStatePayload) { function onDetach(drawLayer,action) { const {plotIdAry}= action.payload; plotIdAry?.forEach( (plotId) => { - if (primePlot(visRoot(),plotId)?.attributes[PlotAttribute.PT_ARY]) { + if (currentP(plotId).plot?.attributes[PlotAttribute.PT_ARY]) { dispatchAttributeChange( { plotId, overlayColorScope:false, changes:{[PlotAttribute.PT_ARY]:undefined, @@ -70,7 +73,7 @@ function creator(initPayload, presetDefaults) { const pairs= { [MouseState.UP.key]: dispatchSelectPoint }; - const actionTypes= [DrawLayerCntlr.SELECT_POINT]; + const actionTypes= [SELECT_POINT]; const options = { isPointData: true, hasPerPlotData: true, @@ -86,7 +89,7 @@ function creator(initPayload, presetDefaults) { function getDrawData(dataType, plotId, drawLayer, action, lastDataRet) { if (dataType!==DataTypes.DATA) return undefined; - const active= isActivePlotView(visRoot(), plotId); + const {active}= currentP(plotId); const drawAry= drawPoints(drawLayer,action, active, plotId); return drawAry || lastDataRet; } @@ -95,13 +98,13 @@ function getDrawData(dataType, plotId, drawLayer, action, lastDataRet) { function getLayerChanges(drawLayer, action) { switch (action.type) { - case DrawLayerCntlr.CHANGE_DRAWING_DEF: + case CHANGE_DRAWING_DEF: return {drawingDef: clone(drawLayer.drawingDef,action.payload.drawingDef)}; - case DrawLayerCntlr.MODIFY_CUSTOM_FIELD: + case MODIFY_CUSTOM_FIELD: return dealWithMods(drawLayer,action); - case DrawLayerCntlr.ATTACH_LAYER_TO_PLOT: + case ATTACH_LAYER_TO_PLOT: return attach(drawLayer); - case DrawLayerCntlr.FORCE_DRAW_LAYER_UPDATE: + case FORCE_DRAW_LAYER_UPDATE: return saveLastData(action.payload.plotIdAry[0]); } } @@ -114,7 +117,7 @@ function attach(drawLayer) { if (!plotId || !data) return; setTimeout( () => { drawLayer.plotIdAry.forEach( (pId) => { - const p= primePlot(visRoot(),pId); + const {plot:p}= currentP(pId); if (p && !p.attributes[PlotAttribute.PT_ARY]) { dispatchAttributeChange({plotId:pId, changes:{[PlotAttribute.PT_ARY]:data}, toAllPlotsInPlotView:false}); dispatchForceDrawLayerUpdate(drawLayer.drawLayerId, pId); @@ -124,15 +127,15 @@ function attach(drawLayer) { } function saveLastData(plotId) { - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); return {lastData:plot?.attributes[PlotAttribute.PT_ARY]}; } function dealWithMods(drawLayer,action) { const {changes,plotIdAry}= action.payload; if (Object.keys(changes).includes('activePt')) { - let plot= primePlot(visRoot()); - if (!plotIdAry.includes(plot.plotId)) plot= primePlot(visRoot(),plotIdAry[0]); + let {plot}= currentP(); + if (!plotIdAry.includes(plot.plotId)) plot= currentP(plotIdAry[0]).plot; const cc= CsysConverter.make(plot); if (!cc) return {}; // const {activePt}= changes; @@ -146,7 +149,7 @@ function dealWithMods(drawLayer,action) { function makeSelectedPt(screenPt,plotId) { - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); const cc= CsysConverter.make(plot); const selPt= cc.getWorldCoords(screenPt); //todo put back return (selPt) ? selPt : cc.getImageCoords(screenPt); @@ -162,7 +165,7 @@ function drawPoints(drawLayer, action, active, plotId) { return Object.values(data).every((v) => isEmpty(v)); }; // attach drawing layer to the plot which is created after the drawing layer - if ( action.type === DrawLayerCntlr.ATTACH_LAYER_TO_PLOT && + if ( action.type === ATTACH_LAYER_TO_PLOT && !isEmptyData() && plotIdAry && plotIdAry.includes(plotId)) { if (drawLayer.plotIdAry) { let dAry; @@ -177,7 +180,7 @@ function drawPoints(drawLayer, action, active, plotId) { } - const plot= primePlot(visRoot(),plotId||plotIdAry?.[0]); + const {plot}= currentP(plotId||plotIdAry?.[0]); if (!plot) return []; const ptAry= plot.attributes[PlotAttribute.PT_ARY] ?? []; diff --git a/src/firefly/js/drawingLayers/FixedMarker.js b/src/firefly/js/drawingLayers/FixedMarker.js index ea12817068..e58c4e0f62 100644 --- a/src/firefly/js/drawingLayers/FixedMarker.js +++ b/src/firefly/js/drawingLayers/FixedMarker.js @@ -12,8 +12,7 @@ import {makeDrawingDef} from '../visualize/draw/DrawingDef.js'; import DrawLayer, {DataTypes,ColorChangeType} from '../visualize/draw/DrawLayer.js'; import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js'; import {formatWorldPt, formatWorldPtToString} from '../visualize/ui/WorldPtFormat'; -import {getActivePlotView} from '../visualize/PlotViewUtil'; -import {visRoot} from '../visualize/ImagePlotCntlr'; +import {currentP} from '../visualize/PlotViewUtil'; import {FixedPtControl} from './FixedPtControl.jsx'; @@ -54,7 +53,7 @@ function getTitle(wp) { return ( {formatWorldPt(wp,5,false)} - {} + {} ); } diff --git a/src/firefly/js/drawingLayers/FixedPtControl.jsx b/src/firefly/js/drawingLayers/FixedPtControl.jsx index c9e1e4473a..872e1da70b 100644 --- a/src/firefly/js/drawingLayers/FixedPtControl.jsx +++ b/src/firefly/js/drawingLayers/FixedPtControl.jsx @@ -2,7 +2,7 @@ import {IconButton, Stack, Tooltip} from '@mui/joy'; import PropTypes from 'prop-types'; import React from 'react'; import CoordinateSys from '../visualize/CoordSys.js'; -import {dispatchRecenter} from '../visualize/ImagePlotCntlr.js'; +import {dispatchRecenter} from '../visualize/ImagePlotDispatch'; import Point from '../visualize/Point.js'; import {CopyToClipboard} from '../visualize/ui/MouseReadout.jsx'; import {formatLonLatToString} from '../visualize/ui/WorldPtFormat.jsx'; diff --git a/src/firefly/js/drawingLayers/FootprintTool.js b/src/firefly/js/drawingLayers/FootprintTool.js index 72ececcf91..4c2fff3389 100644 --- a/src/firefly/js/drawingLayers/FootprintTool.js +++ b/src/firefly/js/drawingLayers/FootprintTool.js @@ -2,30 +2,33 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ import Enum from 'enum'; -import DrawLayerCntlr, {dlRoot, dispatchAttachLayerToPlot, - dispatchCreateDrawLayer, getDlAry} from '../visualize/DrawLayerCntlr.js'; -import {visRoot} from '../visualize/ImagePlotCntlr.js'; import {makeDrawingDef, TextLocation} from '../visualize/draw/DrawingDef.js'; import DrawLayer, {DataTypes, ColorChangeType} from '../visualize/draw/DrawLayer.js'; +import {dispatchAttachLayerToPlot, dispatchCreateDrawLayer} from '../visualize/DrawLayerDispatch'; import {MouseState} from '../visualize/VisMouseSync.js'; import CsysConverter from '../visualize/CsysConverter.js'; -import {primePlot, getDrawLayerById, getDrawLayersByType} from '../visualize/PlotViewUtil.js'; +import {primePlot, getDrawLayerById, getDrawLayersByType, currentP} from '../visualize/PlotViewUtil.js'; import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js'; import {ANGLE_UNIT, OutlineType, getWorldOrImage, findClosestIndex, makeFootprint, lengthSizeUnit, updateFootprintDrawobjAngle, - updateFootprintTranslate, updateFootprintOutline} from '../visualize/draw/MarkerFootprintObj.js'; + updateFootprintTranslate, updateFootprintOutline +} from '../visualize/draw/MarkerFootprintObj.js'; +import {dlRoot, getDlAry} from '../visualize/VisStoreRoots'; import { getCC, cancelTimeoutProcess, initMarkerPos, getPlot, ifUpdateOutline, hasNoProjection, - updateVertexInfo, updateMarkerText, translateForRelocate, getMovement, isGoodPlot, MarkerStatus + updateVertexInfo, updateMarkerText, translateForRelocate, getMovement, isGoodPlot, } from './MarkerTool.js'; import {getFootprintToolUIComponent} from './FootprintToolUI.jsx'; import ShapeDataObj from '../visualize/draw/ShapeDataObj.js'; -import {clone} from '../util/WebUtil.js'; +import {clone} from '../util/WebUtil.js' import {getDS9Region} from '../rpc/PlotServicesJson.js'; import {FootprintFactory} from '../visualize/draw/FootprintFactory.js'; import {makeImagePt} from '../visualize/Point.js'; import {get, set, isArray, has, isNil, isEmpty} from 'lodash'; -import ImagePlotCntlr from '../visualize/ImagePlotCntlr.js'; +import { + ANY_REPLOT, ATTACH_LAYER_TO_PLOT, CHANGE_CENTER_OF_PROJECTION, FOOTPRINT_CREATE, + FOOTPRINT_END, FOOTPRINT_MOVE, FOOTPRINT_START, MODIFY_CUSTOM_FIELD +} from '../visualize/VisConst'; import {relocatable} from './FootprintLocatable.js'; import {MarkerToolUI} from './MarkerToolUI.jsx'; @@ -101,8 +104,8 @@ export function footprintCreateLayerActionCreator(rawAction) { const isPredefined = (!fromFile&&!fromRegionAry); const isInstrument = isPredefined ? (!!instrument) : (relocateBy&&(relocateBy === relocatable.center.key)); const pId = (!plotId || (isArray(plotId) && plotId.length === 0)) ? - get(visRoot(), 'activePlotId') : isArray(plotId) ? plotId[0] : plotId; - const plot = primePlot(visRoot(), pId); + currentP().plotId : isArray(plotId) ? plotId[0] : plotId; + const {plot} = currentP(pId); const cc = CsysConverter.make(plot); const handleRegions = (regionAry) => { @@ -121,7 +124,7 @@ export function footprintCreateLayerActionCreator(rawAction) { if (plot) { const wpt = initMarkerPos(plot); - showFootprintByTimer(dispatcher, DrawLayerCntlr.FOOTPRINT_CREATE, regions, pId, + showFootprintByTimer(dispatcher, FOOTPRINT_CREATE, regions, pId, FootprintStatus.attached, footprintInterval, drawLayerId, {isOutline: true, isRotate}, fpInfo, wpt); @@ -197,7 +200,7 @@ export function footprintStartActionCreator(rawAction) { } if (nextStatus && cc.isPointViewable(refPt)) { - showFootprintByTimer(dispatcher, DrawLayerCntlr.FOOTPRINT_START, regions, plotId, + showFootprintByTimer(dispatcher, FOOTPRINT_START, regions, plotId, nextStatus, footprintInterval, drawLayerId, {isOutline: true, isRotate}, fpInfo, wpt, refPt, move); } }; @@ -222,7 +225,7 @@ export function footprintEndActionCreator(rawAction) { if ([FootprintStatus.relocate, FootprintStatus.attached_relocate, FootprintStatus.rotate].includes(footprintStatus)) { const wpt = getWorldOrImage(currentPt, cc); - showFootprintByTimer(dispatcher, DrawLayerCntlr.FOOTPRINT_END, regions, plotId, + showFootprintByTimer(dispatcher, FOOTPRINT_END, regions, plotId, FootprintStatus.select, footprintInterval, drawLayerId, {isOutline: true, isRotate}, fpInfo, wpt); } @@ -301,7 +304,7 @@ export function footprintMoveActionCreator(rawAction) { } if (!isEmpty(move) && cc.isPointViewable(refPt)) { - showFootprintByTimer(dispatcher, DrawLayerCntlr.FOOTPRINT_MOVE, regions, plotId, + showFootprintByTimer(dispatcher, FOOTPRINT_MOVE, regions, plotId, footprintStatus, 0, drawLayerId, isHandle, fpInfo, wpt, refPt, move); } }; @@ -318,15 +321,12 @@ function creator(initPayload) { const rColor = get(initPayload, ['regions', '0', 'options', 'color'], 'green'); const drawingDef= makeDrawingDef(rColor); const pairs= { - [MouseState.DRAG.key]: DrawLayerCntlr.FOOTPRINT_MOVE, - [MouseState.DOWN.key]: DrawLayerCntlr.FOOTPRINT_START, - [MouseState.UP.key]: DrawLayerCntlr.FOOTPRINT_END + [MouseState.DRAG.key]: FOOTPRINT_MOVE, + [MouseState.DOWN.key]: FOOTPRINT_START, + [MouseState.UP.key]: FOOTPRINT_END }; - const actionTypes= [DrawLayerCntlr.FOOTPRINT_MOVE, - DrawLayerCntlr.FOOTPRINT_START, - DrawLayerCntlr.FOOTPRINT_END, - DrawLayerCntlr.FOOTPRINT_CREATE]; + const actionTypes= [FOOTPRINT_MOVE, FOOTPRINT_START, FOOTPRINT_END, FOOTPRINT_CREATE]; const exclusiveDef= { exclusiveOnDown: true, type : 'anywhere' }; @@ -359,7 +359,7 @@ function creator(initPayload) { function getLayerChanges(drawLayer, action) { const {drawLayerId, plotId} = action.payload; - if (![ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION, ImagePlotCntlr.ANY_REPLOT].includes(action.type) && + if (![CHANGE_CENTER_OF_PROJECTION, ANY_REPLOT].includes(action.type) && (!drawLayerId || drawLayerId !== drawLayer.drawLayerId)) { return null; } @@ -371,7 +371,7 @@ function getLayerChanges(drawLayer, action) { switch (action.type) { - case DrawLayerCntlr.FOOTPRINT_CREATE: + case FOOTPRINT_CREATE: plotIdAry.forEach((pId) => { const plot = getPlot(pId); if (plot && !hasNoProjection(CsysConverter.make(plot))) { @@ -381,9 +381,9 @@ function getLayerChanges(drawLayer, action) { return retV; - case DrawLayerCntlr.FOOTPRINT_START: - case DrawLayerCntlr.FOOTPRINT_MOVE: - case DrawLayerCntlr.FOOTPRINT_END: + case FOOTPRINT_START: + case FOOTPRINT_MOVE: + case FOOTPRINT_END: const {wpt} = action.payload; plotIdAry.forEach((pId) => { @@ -394,7 +394,7 @@ function getLayerChanges(drawLayer, action) { }); return retV; - case DrawLayerCntlr.MODIFY_CUSTOM_FIELD: + case MODIFY_CUSTOM_FIELD: const {fpText, fpTextLoc, angleDeg} = action.payload.changes; if (plotIdAry) { @@ -405,7 +405,7 @@ function getLayerChanges(drawLayer, action) { } } break; - case DrawLayerCntlr.ATTACH_LAYER_TO_PLOT: + case ATTACH_LAYER_TO_PLOT: // if (drawLayer?.drawData?.data) { action.payload?.plotIdAry?.forEach((pId) => { if (isEmpty(dd?.data?.[pId])) { @@ -415,8 +415,8 @@ function getLayerChanges(drawLayer, action) { // } break; - case ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION: - case ImagePlotCntlr.ANY_REPLOT: + case CHANGE_CENTER_OF_PROJECTION: + case ANY_REPLOT: if (plotIdAry) { plotIdAry.forEach((pId) => { if (isGoodPlot(pId) && !isEmpty(get(dd, ['data', pId]))) { @@ -593,7 +593,7 @@ function createFootprintObjs(action, dl, plotId, wpt, prevRet) { updateHandle(isHandle, footprintObj); } - if ([ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION, ImagePlotCntlr.ANY_REPLOT].includes(action.type) && !footprintStatus) { + if ([CHANGE_CENTER_OF_PROJECTION, ANY_REPLOT].includes(action.type) && !footprintStatus) { footprintStatus = get(dl.drawData, [DataTypes.DATA, plotId, 'actionInfo', 'footprintStatus'], FootprintStatus.select); } footprintObj.plotId = plotId; @@ -682,10 +682,10 @@ function attachToNewPlot(drawLayer, newPlotId) { if (!existPlotId && !drawLayer.lastDrawData) return drawLayer; - const { text, textLoc, renderOptions, actionInfo, translation, angle, angleUnit, regions, isRotatable, pts} + const { text, textLoc, renderOptions, actionInfo, translation, angle, angleUnit, regions, isRotatable} = drawLayer?.drawData?.data?.[existPlotId] ?? drawLayer.lastDrawData; - const plot = primePlot(visRoot(), newPlotId); + const {plot} = currentP(newPlotId); const cc = CsysConverter.make(plot); if (hasNoProjection(cc)) { return drawLayer; diff --git a/src/firefly/js/drawingLayers/FootprintToolUI.jsx b/src/firefly/js/drawingLayers/FootprintToolUI.jsx index 37a3ef3aaa..81c4e4a0a5 100644 --- a/src/firefly/js/drawingLayers/FootprintToolUI.jsx +++ b/src/firefly/js/drawingLayers/FootprintToolUI.jsx @@ -7,15 +7,15 @@ import React, {PureComponent} from 'react'; import PropTypes from 'prop-types'; import {flux} from '../core/ReduxFlux.js'; import {ListBoxInputFieldView} from '../ui/ListBoxInputField.jsx'; +import {dispatchModifyCustomField} from '../visualize/DrawLayerDispatch'; import {formatWorldPt} from '../visualize/ui/WorldPtFormat.jsx'; +import {DRAWING_LAYER_KEY} from '../visualize/VisConst'; import {convertAngle} from '../visualize/VisUtil.js'; import {TextLocation} from '../visualize/draw/DrawingDef.js'; -import {dispatchModifyCustomField, DRAWING_LAYER_KEY} from '../visualize/DrawLayerCntlr.js'; import {addFootprintDrawLayer} from '../visualize/ui/MarkerDropDownView.jsx'; import {ANGLE_UNIT} from '../visualize/draw/MarkerFootprintObj.js'; -import {primePlot, getDrawLayerById} from '../visualize/PlotViewUtil.js'; +import {currentP, getDrawLayerById} from '../visualize/PlotViewUtil.js'; import CsysConverter from '../visualize/CsysConverter.js'; -import {visRoot} from '../visualize/ImagePlotCntlr.js'; import {InputFieldView} from '../ui/InputFieldView.jsx'; import {isNil} from 'lodash'; import {sprintf} from '../externalSource/sprintf'; @@ -35,7 +35,7 @@ class FootprintToolUI extends PureComponent { const angleDeg = `${formatAngle(convertAngle(angleUnit.key, 'deg', angle))}`; const {fpInfo} = this.props.drawLayer; const {currentPt} = fpObj?.actionInfo ?? {}; - const plot= primePlot(visRoot(),this.props.pv.plotId); + const {plot}= currentP(this.props.pv.plotId); this.csys = CsysConverter.make(plot); this.state = {fpText: text, fpTextLoc: textLoc.key, angleDeg, fpInfo, diff --git a/src/firefly/js/drawingLayers/HiPSGrid.js b/src/firefly/js/drawingLayers/HiPSGrid.js index 307eefadf2..64aa54333c 100644 --- a/src/firefly/js/drawingLayers/HiPSGrid.js +++ b/src/firefly/js/drawingLayers/HiPSGrid.js @@ -3,8 +3,10 @@ */ -import ImagePlotCntlr, {visRoot} from '../visualize/ImagePlotCntlr.js'; -import DrawLayerCntlr from '../visualize/DrawLayerCntlr.js'; +import { + ANY_REPLOT, ATTACH_LAYER_TO_PLOT, CHANGE_CENTER_OF_PROJECTION, CHANGE_VISIBILITY, MODIFY_CUSTOM_FIELD +} from '../visualize/VisConst'; +import {visRoot} from '../visualize/VisStoreRoots'; import {primePlot, isDrawLayerVisible} from '../visualize/PlotViewUtil.js'; import { getHiPSNorderlevel, getVisibleHiPSCells, @@ -54,10 +56,10 @@ function creator(initPayload, presetDefaults) { function getLayerChanges(drawLayer, action) { switch (action.type) { - case ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION: - case ImagePlotCntlr.ANY_REPLOT: + case CHANGE_CENTER_OF_PROJECTION: + case ANY_REPLOT: return {drawData:computeDrawData(drawLayer,action, drawLayer.gridType,drawLayer.gridLockLevel)}; - case DrawLayerCntlr.ATTACH_LAYER_TO_PLOT: + case ATTACH_LAYER_TO_PLOT: const {plotId} = action.payload; let {plotIdAry}= action.payload; @@ -69,9 +71,9 @@ function getLayerChanges(drawLayer, action) { return {title, drawData:computeDrawData(drawLayer,action,drawLayer.gridType,drawLayer.gridLockLevel) }; - case DrawLayerCntlr.MODIFY_CUSTOM_FIELD: + case MODIFY_CUSTOM_FIELD: return dealWithMods(drawLayer,action); - case DrawLayerCntlr.CHANGE_VISIBILITY: + case CHANGE_VISIBILITY: if (action.payload.visible) { return {drawData:computeDrawData(drawLayer,action, drawLayer.gridType,drawLayer.gridLockLevel, true)}; } diff --git a/src/firefly/js/drawingLayers/HiPSGridlUI.jsx b/src/firefly/js/drawingLayers/HiPSGridlUI.jsx index 18f54ea411..a6064ba418 100644 --- a/src/firefly/js/drawingLayers/HiPSGridlUI.jsx +++ b/src/firefly/js/drawingLayers/HiPSGridlUI.jsx @@ -8,7 +8,8 @@ import React from 'react'; import PropTypes from 'prop-types'; import {RadioGroupInputFieldView} from '../ui/RadioGroupInputFieldView.jsx'; import {ListBoxInputFieldView} from '../ui/ListBoxInputField.jsx'; -import {dispatchModifyCustomField} from '../visualize/DrawLayerCntlr.js'; + +import {dispatchModifyCustomField} from '../visualize/DrawLayerDispatch'; import {getMaxDisplayableHiPSGridLevel, getHiPSNorderlevel} from '../visualize/HiPSUtil.js'; import {primePlot} from '../visualize/PlotViewUtil.js'; diff --git a/src/firefly/js/drawingLayers/HiPSMOC.js b/src/firefly/js/drawingLayers/HiPSMOC.js index 2758e10ed9..2738972f91 100644 --- a/src/firefly/js/drawingLayers/HiPSMOC.js +++ b/src/firefly/js/drawingLayers/HiPSMOC.js @@ -7,17 +7,20 @@ import {makeDrawingDef, TextLocation, Style} from '../visualize/draw/DrawingDef. import DrawLayer, {DataTypes, ColorChangeType} from '../visualize/draw/DrawLayer.js'; import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js'; import {primePlot, getDrawLayerById, getPlotViewIdListInOverlayGroup, getFoV} from '../visualize/PlotViewUtil.js'; -import DrawLayerCntlr, {DRAWING_LAYER_KEY, dispatchUpdateDrawLayer, dlRoot} from '../visualize/DrawLayerCntlr.js'; +import {dispatchModifyCustomField, dispatchUpdateDrawLayer} from '../visualize/DrawLayerDispatch'; import MocObj, {createDrawObjsInMoc, setMocDisplayOrder, MocGroup} from '../visualize/draw/MocObj.js'; import {getUIComponent} from './HiPSMOCUI.jsx'; -import ImagePlotCntlr, {visRoot} from '../visualize/ImagePlotCntlr.js'; +import { + ANY_REPLOT, ATTACH_LAYER_TO_PLOT, CHANGE_CENTER_OF_PROJECTION, CHANGE_DRAWING_DEF, CHANGE_VISIBILITY, + DRAWING_LAYER_KEY, MODIFY_CUSTOM_FIELD, REGION_SELECT +} from '../visualize/VisConst'; import {getMetaEntry, getTblById} from '../tables/TableUtil.js'; import {makeTblRequest} from '../tables/TableRequestUtil.js'; -import {MAX_ROW} from '../tables/TableRequestUtil.js'; +import {MAX_ROW} from '../tables/TableConst'; import { dispatchAddWorkingTask, getAppOptions} from '../core/AppDataCntlr.js'; import {doFetchTable} from '../tables/TableUtil'; import {logger} from '../util/Logger.js'; -import {dispatchModifyCustomField, getDlAry} from '../visualize/DrawLayerCntlr'; +import {dlRoot, getDlAry, visRoot} from '../visualize/VisStoreRoots'; import {cloneRequest} from '../tables/TableRequestUtil'; import {dispatchAddActionWatcher} from '../core/MasterSaga'; import {MetaConst} from '../data/MetaConst'; @@ -99,7 +102,7 @@ function loadMocFitsWatcher(action, cancelSelf, params, dispatch, getState) { dispatchModifyCustomField(tbl_id, {mocTable:tableModel,autoUsesOnlyOutline}); const visiblePlotIdAry =getVisiblePlotIdsByDrawlayerId(id, getState); visiblePlotIdAry.forEach((pId) => { - dispatch({type: ImagePlotCntlr.ANY_REPLOT, payload: {plotId: pId}}); + dispatch({type: ANY_REPLOT, payload: {plotId: pId}}); }); } } @@ -112,7 +115,7 @@ function loadMocFitsWatcher(action, cancelSelf, params, dispatch, getState) { } else { const vPlotIds =getVisiblePlotIdsByDrawlayerId(id, getState); vPlotIds.forEach((pId) => { - dispatch({type: ImagePlotCntlr.ANY_REPLOT, payload: {plotId: pId}}); + dispatch({type: ANY_REPLOT, payload: {plotId: pId}}); }); } } @@ -140,7 +143,7 @@ function creator(initPayload) { }; // const actionTypes = [DrawLayerCntlr.REGION_SELECT, TABLE_LOADED]; - const actionTypes = [DrawLayerCntlr.REGION_SELECT]; + const actionTypes = [REGION_SELECT]; const {mocFitsInfo={},color= getNextColor(), mocGroupDefColorId}= initPayload || {}; const {tbl_id, tablePreloaded} = mocFitsInfo; const id = tbl_id || (initPayload?.drawLayerId ?? `${ID}-${idCnt}`); @@ -188,7 +191,7 @@ function creator(initPayload) { dispatchAddActionWatcher({ callback:loadMocFitsWatcher, params: {id: dl.drawLayerId, mocFitsInfo}, - actions:[DrawLayerCntlr.CHANGE_VISIBILITY, DrawLayerCntlr.ATTACH_LAYER_TO_PLOT] + actions:[CHANGE_VISIBILITY, ATTACH_LAYER_TO_PLOT] }); return dl; @@ -249,11 +252,6 @@ function getTitle(dl, pIdAry, isLoading=false) { } -function showMessage(text, bShow = false) { - if (bShow) { - console.log(text); - } -} /** * state update on the drawlayer change * @param drawLayer @@ -267,7 +265,7 @@ function getLayerChanges(drawLayer, action) { if (drawLayerId && drawLayerId !== drawLayer.drawLayerId) return null; switch (action.type) { - case DrawLayerCntlr.ATTACH_LAYER_TO_PLOT: + case ATTACH_LAYER_TO_PLOT: if (!plotIdAry && !plotId) return null; const {visible} = action.payload; @@ -282,7 +280,7 @@ function getLayerChanges(drawLayer, action) { return {title: tObj, updateStatusAry}; - case DrawLayerCntlr.MODIFY_CUSTOM_FIELD: + case MODIFY_CUSTOM_FIELD: const {fillStyle, targetPlotId, mocTable} = action.payload.changes; if (fillStyle && targetPlotId) { @@ -322,14 +320,14 @@ function getLayerChanges(drawLayer, action) { } break; - case DrawLayerCntlr.CHANGE_VISIBILITY: + case CHANGE_VISIBILITY: if (action.payload.visible) { const pIdAry = plotIdAry ? plotIdAry :[plotId]; return Object.assign({}, {title: getTitle(drawLayer, pIdAry, action.payload.visible && !drawLayer.mocTable)}); } break; - case DrawLayerCntlr.CHANGE_DRAWING_DEF: // from color change + case CHANGE_DRAWING_DEF: // from color change const {color} = action.payload.drawingDef || {}; const newMocObj = createMocObj(drawLayer, undefined, undefined); const [r,g,b,savedAlpha]= toRGBA(color); @@ -378,7 +376,7 @@ function changeMocDrawingColor(dl, pId) { const dObjs = get(dl.drawData, [DataTypes.DATA, pId],[]); return dObjs.map((oneObj) => { - if (oneObj.fillColor && oneObj.fillColor != fillColor) { + if (oneObj.fillColor && oneObj.fillColor !== fillColor) { return {...oneObj, fillColor}; } else { return oneObj; @@ -535,12 +533,11 @@ function abortLastAsyncUpdateIfRunning(updateStatusAry, pId) { * @param action */ function asyncComputeDrawData(drawLayer, action) { - const forAction = [ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION, ImagePlotCntlr.ANY_REPLOT, - DrawLayerCntlr.MODIFY_CUSTOM_FIELD, DrawLayerCntlr.CHANGE_DRAWING_DEF]; + const forAction = [CHANGE_CENTER_OF_PROJECTION, ANY_REPLOT, MODIFY_CUSTOM_FIELD, CHANGE_DRAWING_DEF]; if (!forAction.includes(action.type) || !drawLayer.mocObj) return; const {mocStyle={}} = drawLayer; - if (action.type === DrawLayerCntlr.MODIFY_CUSTOM_FIELD) { + if (action.type === MODIFY_CUSTOM_FIELD) { const {fillStyle, targetPlotId} = action.payload.changes; if (!fillStyle || !targetPlotId) return; @@ -549,9 +546,9 @@ function asyncComputeDrawData(drawLayer, action) { targetPlotId), drawLayer, targetPlotId); mocRedraw(newDl,action); - } else if (action.type === ImagePlotCntlr.ANY_REPLOT) { + } else if (action.type === ANY_REPLOT) { mocRedraw(drawLayer,action); - } else if (action.type === DrawLayerCntlr.CHANGE_DRAWING_DEF) { + } else if (action.type === CHANGE_DRAWING_DEF) { const {plotIdAry} = drawLayer; const dd = {...drawLayer.drawData}; @@ -571,7 +568,7 @@ function mocRedraw(drawLayer,action) { const {plotId, plotIdAry} = action.payload; const {visiblePlotIdAry, updateStatusAry={}} = drawLayer; - const pIdAry= plotIdAry ?? action.type === ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION + const pIdAry= plotIdAry ?? action.type === CHANGE_CENTER_OF_PROJECTION ? getPlotViewIdListInOverlayGroup(visRoot(), plotId) : plotId ? [plotId] : []; diff --git a/src/firefly/js/drawingLayers/HiPSMOCUI.jsx b/src/firefly/js/drawingLayers/HiPSMOCUI.jsx index e7815cf93a..61a792359f 100644 --- a/src/firefly/js/drawingLayers/HiPSMOCUI.jsx +++ b/src/firefly/js/drawingLayers/HiPSMOCUI.jsx @@ -6,8 +6,8 @@ import React from 'react'; import {object} from 'prop-types'; import {RadioGroupInputFieldView} from '../ui/RadioGroupInputFieldView.jsx'; -import {dispatchModifyCustomField} from '../visualize/DrawLayerCntlr.js'; import {Style} from '../visualize/draw/DrawingDef.js'; +import {dispatchModifyCustomField} from '../visualize/DrawLayerDispatch'; const options= [ {label: 'Outline', value: Style.DESTINATION_OUTLINE.key}, diff --git a/src/firefly/js/drawingLayers/ImageLineBasedFootprint.js b/src/firefly/js/drawingLayers/ImageLineBasedFootprint.js index d9555d4356..8382792997 100644 --- a/src/firefly/js/drawingLayers/ImageLineBasedFootprint.js +++ b/src/firefly/js/drawingLayers/ImageLineBasedFootprint.js @@ -5,15 +5,18 @@ import {get, set, has, isEmpty, isString, isUndefined, pickBy} from 'lodash'; import {makeDrawingDef, TextLocation, Style} from '../visualize/draw/DrawingDef.js'; import DrawLayer, {DataTypes, ColorChangeType} from '../visualize/draw/DrawLayer.js'; import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js'; +import {dispatchSelectRegion} from '../visualize/DrawLayerDispatch'; +import { + ATTACH_LAYER_TO_PLOT, CHANGE_DRAWING_DEF, MODIFY_CUSTOM_FIELD, REGION_SELECT, RegionSelStyle +} from '../visualize/VisConst'; +import {dlRoot} from '../visualize/VisStoreRoots'; import {getSelectedPts} from '../visualize/WebPlotAnalysis'; -import {primePlot, getAllDrawLayersForPlot} from '../visualize/PlotViewUtil.js'; -import DrawLayerCntlr, {RegionSelStyle, dlRoot, dispatchSelectRegion} from '../visualize/DrawLayerCntlr.js'; +import {primePlot, getAllDrawLayersForPlot, currentP} from '../visualize/PlotViewUtil.js'; import {clone} from '../util/WebUtil.js'; import {MouseState} from '../visualize/VisMouseSync.js'; import {convertConnectedObjsToDrawObjs, getImageCoordsOnFootprint, drawHighlightFootprintObj} from '../visualize/draw/ImageLineBasedObj.js'; import {getUIComponent} from './ImageLineFootPrintUI.jsx'; import {rateOpacity} from '../util/Color.js'; -import {visRoot} from '../visualize/ImagePlotCntlr.js'; import CsysConverter from '../visualize/CsysConverter.js'; import {DrawSymbol} from '../visualize/draw/DrawSymbol.js'; import {dispatchTableHighlight, dispatchTableSelect, dispatchTableFilter} from '../tables/TablesCntlr.js'; @@ -72,7 +75,7 @@ function creator(initPayload) { isPointData:true }; - const actionTypes = [DrawLayerCntlr.REGION_SELECT, DrawLayerCntlr.CHANGE_DRAWING_DEF]; + const actionTypes = [REGION_SELECT, CHANGE_DRAWING_DEF]; const id = get(initPayload, 'drawLayerId', `${ID}-${idCnt}`); const dl = DrawLayer.makeDrawLayer( id, TYPE_ID, get(initPayload, 'title', 'Lsst footprint '+id), @@ -98,7 +101,7 @@ function highlightChange(mouseStatePayload) { let index = 0; const {connectedObjs, pixelSys} = get(drawLayer, 'imageLineBasedFP') || {}; - const plot = primePlot(visRoot(), plotId); + const {plot} = currentP(plotId); const cc = CsysConverter.make(plot); const tPt = getImageCoordsOnFootprint(screenPt, cc, pixelSys); const {tableRequest} = drawLayer; @@ -175,7 +178,7 @@ function getLayerChanges(drawLayer, action) { const dd = Object.assign({}, drawLayer.drawData); switch (action.type) { - case DrawLayerCntlr.ATTACH_LAYER_TO_PLOT: + case ATTACH_LAYER_TO_PLOT: if (!plotIdAry && !plotId) return null; const pIdAry = plotIdAry ? plotIdAry :[plotId]; @@ -183,7 +186,7 @@ function getLayerChanges(drawLayer, action) { return {title: tObj}; - case DrawLayerCntlr.MODIFY_CUSTOM_FIELD: + case MODIFY_CUSTOM_FIELD: const pId = plotId ? plotId : (plotIdAry ? plotIdAry[0]: null); if (!pId) return null; @@ -225,7 +228,7 @@ function getLayerChanges(drawLayer, action) { return Object.assign({}, changesUpdate, {drawingDef: drawingDefChanges}, {drawData: dd}); - case DrawLayerCntlr.REGION_SELECT: + case REGION_SELECT: const {selectedRegion} = action.payload; let hideFPId = ''; @@ -246,7 +249,7 @@ function getLayerChanges(drawLayer, action) { return Object.assign({}, {highlightedFootprint: selectedRegion, drawData: dd, hideFPId}); - case DrawLayerCntlr.CHANGE_DRAWING_DEF: + case CHANGE_DRAWING_DEF: const ptId = plotId ? plotId : (plotIdAry ? plotIdAry[0]: null); if (!ptId) return null; @@ -336,7 +339,7 @@ function plotHighlightRegion(drawLayer, highlightedFootprint, plotId, drawingDef return []; } - return drawHighlightFootprintObj(highlightedFootprint, primePlot(visRoot(), plotId), drawingDef); + return drawHighlightFootprintObj(highlightedFootprint, currentP(plotId).plot, drawingDef); } diff --git a/src/firefly/js/drawingLayers/ImageLineFootPrintUI.jsx b/src/firefly/js/drawingLayers/ImageLineFootPrintUI.jsx index 30768386de..d7e1f59e81 100644 --- a/src/firefly/js/drawingLayers/ImageLineFootPrintUI.jsx +++ b/src/firefly/js/drawingLayers/ImageLineFootPrintUI.jsx @@ -6,8 +6,8 @@ import React from 'react'; import PropTypes from 'prop-types'; import {RadioGroupInputFieldView} from '../ui/RadioGroupInputFieldView.jsx'; -import {dispatchChangeDrawingDef} from '../visualize/DrawLayerCntlr.js'; import {Style} from '../visualize/draw/DrawingDef.js'; +import {dispatchChangeDrawingDef} from '../visualize/DrawLayerDispatch'; const options= [ {label: 'outline', value: 'outline'}, {label: 'outline/text', value: 'outline_text'}, diff --git a/src/firefly/js/drawingLayers/ImageOutline.js b/src/firefly/js/drawingLayers/ImageOutline.js index 8fae836971..2e27874bde 100644 --- a/src/firefly/js/drawingLayers/ImageOutline.js +++ b/src/firefly/js/drawingLayers/ImageOutline.js @@ -4,9 +4,8 @@ import {get, isArray} from 'lodash'; -import ImagePlotCntlr, {visRoot} from '../visualize/ImagePlotCntlr.js'; -import DrawLayerCntlr from '../visualize/DrawLayerCntlr.js'; -import {primePlot, isDrawLayerVisible} from '../visualize/PlotViewUtil.js'; +import {ATTACH_LAYER_TO_PLOT} from '../visualize/VisConst'; +import {isDrawLayerVisible, currentP} from '../visualize/PlotViewUtil.js'; import {PlotAttribute} from '../visualize/PlotAttribute.js'; import FootprintObj from '../visualize/draw/FootprintObj.js'; import ShapeDataObj from '../visualize/draw/ShapeDataObj.js'; @@ -57,9 +56,7 @@ function getDrawData(dataType, plotId, drawLayer, action, lastDataRet) { function getLayerChanges(drawLayer, action) { switch (action.type) { - case ImagePlotCntlr.ANY_REPLOT: - break; - case DrawLayerCntlr.ATTACH_LAYER_TO_PLOT: + case ATTACH_LAYER_TO_PLOT: const {plotId}= action.payload; let {plotIdAry}= action.payload; if (!plotIdAry && !plotId) return null; @@ -74,26 +71,20 @@ function getLayerChanges(drawLayer, action) { plotIdAry.forEach((id) => title[id] = getTitle(id)); } return {title}; - - case DrawLayerCntlr.MODIFY_CUSTOM_FIELD: - break; } return null; } function getTitle(plotId) { - const plot= primePlot(visRoot(),plotId); - const lastTitle= plot.attributes[PlotAttribute.OUTLINEIMAGE_TITLE]; + const lastTitle= currentP(plotId).plot?.attributes[PlotAttribute.OUTLINEIMAGE_TITLE]; return `${lastTitle?lastTitle:'Image'} outline`; } function computeDrawData(drawLayer, plotId) { if (!plotId) return null; - const plot= primePlot(visRoot(),plotId); - if (!plot) return []; - - return computeDrawobj(drawLayer, plot); + const {plot}= currentP(plotId); + return plot ? computeDrawobj(drawLayer, plot) : []; } @@ -134,14 +125,14 @@ function computeDrawobj(dl, plot) { if (drawObj) { if (text && !textLoc) { - textLoc = drawObjTextLoc(drawObj); + drawObjTextLoc(drawObj); } } else { // dynamic get data from attribute if (plot.attributes[PlotAttribute.OUTLINEIMAGE_DRAWOBJ]) { drawObj = plot.attributes[PlotAttribute.OUTLINEIMAGE_DRAWOBJ]; if (text && !textLoc && drawObj) { - textLoc = drawObjTextLoc(drawObj); + drawObjTextLoc(drawObj); } } else if (plot.attributes[PlotAttribute.OUTLINEIMAGE_BOUNDS]) { diff --git a/src/firefly/js/drawingLayers/ImageRoot.js b/src/firefly/js/drawingLayers/ImageRoot.js index d56b938cb0..3bc74d7e58 100644 --- a/src/firefly/js/drawingLayers/ImageRoot.js +++ b/src/firefly/js/drawingLayers/ImageRoot.js @@ -8,9 +8,9 @@ import {sprintf} from '../externalSource/sprintf'; import {makeDrawingDef} from '../visualize/draw/DrawingDef.js'; import DrawLayer, {ColorChangeType} from '../visualize/draw/DrawLayer.js'; import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js'; -import {getPlotViewById, primePlot} from '../visualize/PlotViewUtil'; -import {dispatchChangeHiPS, dispatchChangeImageVisibility, visRoot} from '../visualize/ImagePlotCntlr'; -import DrawLayerCntlr from '../visualize/DrawLayerCntlr'; +import {currentP} from '../visualize/PlotViewUtil'; +import {dispatchChangeHiPS, dispatchChangeImageVisibility} from '../visualize/ImagePlotDispatch'; +import {ATTACH_LAYER_TO_PLOT} from '../visualize/VisConst'; import {isHiPS, isImage} from '../visualize/WebPlot'; const ID= 'IMAGE_ROOT'; @@ -30,7 +30,7 @@ function onVisibilityChange(drawLayer,action) { function creator(initPayload, presetDefaults) { const {plotId, layersPanelLayoutId}= initPayload; - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); const drawingDef= { ...makeDrawingDef(plot?.blankColor??'yellow', {fontWeight:'bolder'} ), ...presetDefaults}; @@ -55,8 +55,7 @@ function getLayerChanges(drawLayer, action) { const {payload,type}= action; const {plotId}= drawLayer; if (!plotId) return null; - const pv= getPlotViewById(visRoot(),plotId); - const plot= primePlot(pv); + const {pv,plot}= currentP(plotId); if (!pv || !plot) return null; const canUserHide= !plot.blank; const canUserChangeColor= plot.blank ? ColorChangeType.DYNAMIC : ColorChangeType.DISABLE; @@ -64,12 +63,11 @@ function getLayerChanges(drawLayer, action) { setTimeout(() => dispatchChangeHiPS({plotId,blankColor:payload.drawingDef.color}), 5); } switch (type) { - case DrawLayerCntlr.ATTACH_LAYER_TO_PLOT: + case ATTACH_LAYER_TO_PLOT: return { title: getTitle(pv, plot, drawLayer), canUserHide, canUserChangeColor}; default: return { title: getTitle(pv, plot, drawLayer), canUserHide, canUserChangeColor}; } - return undefined; } diff --git a/src/firefly/js/drawingLayers/MarkerTool.js b/src/firefly/js/drawingLayers/MarkerTool.js index c337b535c4..a59260d7e3 100644 --- a/src/firefly/js/drawingLayers/MarkerTool.js +++ b/src/firefly/js/drawingLayers/MarkerTool.js @@ -2,15 +2,13 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ import React from 'react'; -import DrawLayerCntlr, {dlRoot, dispatchAttachLayerToPlot, - dispatchCreateDrawLayer, getDlAry} from '../visualize/DrawLayerCntlr.js'; -import {visRoot} from '../visualize/ImagePlotCntlr.js'; import {makeDrawingDef, TextLocation} from '../visualize/draw/DrawingDef.js'; import DrawLayer, {DataTypes,ColorChangeType} from '../visualize/draw/DrawLayer.js'; +import {dispatchAttachLayerToPlot, dispatchCreateDrawLayer} from '../visualize/DrawLayerDispatch'; import {MouseState} from '../visualize/VisMouseSync.js'; import {PlotAttribute} from '../visualize/PlotAttribute.js'; import CsysConverter from '../visualize/CsysConverter.js'; -import {primePlot, getDrawLayerById} from '../visualize/PlotViewUtil.js'; +import {primePlot, getDrawLayerById, currentP} from '../visualize/PlotViewUtil.js'; import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js'; import {getWorldOrImage, makeMarker, findClosestIndex, updateFootprintTranslate, updateMarkerSize, updateFootprintDrawobjText, updateFootprintOutline, lengthSizeUnit, isOutlineBoxOriginal, @@ -19,10 +17,14 @@ import {getDrawobjArea} from '../visualize/draw/ShapeHighlight.js'; import ShapeDataObj, {lengthToScreenPixel, lengthToImagePixel} from '../visualize/draw/ShapeDataObj.js'; import {makeDevicePt, makeImagePt} from '../visualize/Point.js'; import {clone} from '../util/WebUtil.js'; -import ImagePlotCntlr from '../visualize/ImagePlotCntlr.js'; +import { + ANY_REPLOT, ATTACH_LAYER_TO_PLOT, CHANGE_CENTER_OF_PROJECTION, MARKER_CREATE, MARKER_END, MARKER_MOVE, MARKER_START, + MODIFY_CUSTOM_FIELD +} from '../visualize/VisConst'; import {get, set, has, isArray, isEmpty} from 'lodash'; import Enum from 'enum'; import {hasWCSProjection} from '../visualize/PlotViewUtil'; +import {dlRoot, getDlAry} from '../visualize/VisStoreRoots'; import {MarkerToolUI} from './MarkerToolUI.jsx'; const editHelpText='Click the marker and drag to move, click corner and drag to resize'; @@ -38,10 +40,9 @@ export const markerInterval = 3000; // time interval for showing marker with han export default {factoryDef, TYPE_ID}; // every draw layer must default export with factoryDef and TYPE_ID export var cancelTimeoutProcess = (toP) => { if (toP) clearTimeout(toP); }; -export const getPlot = (pId) => ( primePlot(visRoot(), pId) ); +export const getPlot = (pId) => ( currentP(pId).plot ); export var getCC = (plotId) => { - var plot = primePlot(visRoot(), plotId); - return CsysConverter.make(plot); + return CsysConverter.make(currentP(plotId).plot); }; export const isGoodPlot = (pId) => (Boolean(getPlot(pId))); @@ -72,12 +73,12 @@ export function markerToolCreateLayerActionCreator(rawAction) { // plotId could be an array or single value var pId = (!plotId || (isArray(plotId)&&plotId.length === 0)) ? - get(visRoot(), 'activePlotId') : isArray(plotId) ? plotId[0] : plotId; + currentP().plotId : isArray(plotId) ? plotId[0] : plotId; if (pId) { dispatchAttachLayerToPlot(drawLayerId, pId, attachPlotGroup); - showMarkersByTimer(dispatcher, DrawLayerCntlr.MARKER_CREATE, pId, + showMarkersByTimer(dispatcher, MARKER_CREATE, pId, MarkerStatus.attached, markerInterval, drawLayerId, {isOutline: true, isResize:true}); } }; @@ -135,7 +136,7 @@ export function markerToolStartActionCreator(rawAction) { } if (nextStatus && cc.isPointViewable(refPt)) { - showMarkersByTimer(dispatcher, DrawLayerCntlr.MARKER_START, plotId, nextStatus, markerInterval, + showMarkersByTimer(dispatcher, MARKER_START, plotId, nextStatus, markerInterval, drawLayerId, {isOutline: true, isResize:true}, wpt, evenSize(currentSize), unitT, refPt, move); } }; @@ -160,7 +161,7 @@ export function markerToolEndActionCreator(rawAction) { if ([MarkerStatus.relocate, MarkerStatus.attached_relocate, MarkerStatus.resize].includes(markerStatus)) { var wpt = getWorldOrImage(currentPt, getCC(plotId)); - showMarkersByTimer(dispatcher, DrawLayerCntlr.MARKER_END, plotId, + showMarkersByTimer(dispatcher, MARKER_END, plotId, MarkerStatus.select, markerInterval, drawLayerId, {isOutline, isResize}, wpt, evenSize(currentSize), unitT); } }; @@ -227,7 +228,7 @@ export function markerToolMoveActionCreator(rawAction) { // resize (newDize) or relocate (wpt), status remains the same if (!isEmpty(move) && cc.isPointViewable(refPt)) { - showMarkersByTimer(dispatcher, DrawLayerCntlr.MARKER_MOVE, plotId, + showMarkersByTimer(dispatcher, MARKER_MOVE, plotId, markerStatus, 0, drawLayerId, isHandle, wpt, newSize, unitT, refPt, move); } }; @@ -243,17 +244,14 @@ function creator(initPayload) { var drawingDef= makeDrawingDef('red'); var pairs= { - [MouseState.DRAG.key]: DrawLayerCntlr.MARKER_MOVE, - [MouseState.DOWN.key]: DrawLayerCntlr.MARKER_START, - [MouseState.UP.key]: DrawLayerCntlr.MARKER_END + [MouseState.DRAG.key]: MARKER_MOVE, + [MouseState.DOWN.key]: MARKER_START, + [MouseState.UP.key]: MARKER_END }; //var actionTypes=[DrawLayerCntlr.MARKER_LOC]; - var actionTypes= [DrawLayerCntlr.MARKER_MOVE, - DrawLayerCntlr.MARKER_START, - DrawLayerCntlr.MARKER_END, - DrawLayerCntlr.MARKER_CREATE]; + var actionTypes= [MARKER_MOVE, MARKER_START, MARKER_END, MARKER_CREATE]; var exclusiveDef= { exclusiveOnDown: true, type : 'anywhere' }; @@ -284,7 +282,7 @@ function creator(initPayload) { */ function getLayerChanges(drawLayer, action) { const {drawLayerId, plotId} = action.payload; - if (![ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION, ImagePlotCntlr.ANY_REPLOT].includes(action.type) && + if (![CHANGE_CENTER_OF_PROJECTION, ANY_REPLOT].includes(action.type) && (!drawLayerId || drawLayerId !== drawLayer.drawLayerId)) { return null; } @@ -292,11 +290,12 @@ function getLayerChanges(drawLayer, action) { const dd = Object.assign({}, drawLayer.drawData); const {plotIdAry=[]} = drawLayer; var {wpt, size, unitT} = action.payload; - var retV = drawLayer; + let retV = drawLayer; + let wptObj; switch (action.type) { - case DrawLayerCntlr.MARKER_CREATE: - const activePId = visRoot().activePlotId; + case MARKER_CREATE: + const activePId = currentP().plotId; const sizePlot = lengthSizeUnit(getCC(activePId), MARKER_SIZE, ShapeDataObj.UnitType.PIXEL, ShapeDataObj.UnitType.PIXEL); const cc = getCC(activePId); @@ -317,12 +316,11 @@ function getLayerChanges(drawLayer, action) { return retV; - case DrawLayerCntlr.MARKER_START: - case DrawLayerCntlr.MARKER_MOVE: - case DrawLayerCntlr.MARKER_END: - var wptObj; + case MARKER_START: + case MARKER_MOVE: + case MARKER_END: - if (DrawLayerCntlr.MARKER_MOVE === action.type && action.payload.move.newSize) { + if (MARKER_MOVE === action.type && action.payload.move.newSize) { const {newSize} = action.payload.move; let marker = get(dd, [DataTypes.DATA, plotId, 'drawObjAry', '0']); @@ -379,7 +377,7 @@ function getLayerChanges(drawLayer, action) { return retV; - case DrawLayerCntlr.ATTACH_LAYER_TO_PLOT: + case ATTACH_LAYER_TO_PLOT: if (!isEmpty(get(drawLayer, ['drawData', 'data']))) { get(action.payload, 'plotIdAry', []).forEach((pId) => { if (isEmpty(get(dd, ['data', pId]))) { @@ -389,15 +387,15 @@ function getLayerChanges(drawLayer, action) { } return retV; - case DrawLayerCntlr.MODIFY_CUSTOM_FIELD: + case MODIFY_CUSTOM_FIELD: const {markerText, markerTextLoc} = action.payload.changes; if (plotIdAry) { return updateMarkerText(markerText, markerTextLoc, dd[DataTypes.DATA], plotIdAry); } return {}; - case ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION: - case ImagePlotCntlr.ANY_REPLOT: + case CHANGE_CENTER_OF_PROJECTION: + case ANY_REPLOT: if (plotIdAry) { plotIdAry.forEach((pId) => { if (isGoodPlot(pId) && !isEmpty(get(dd, ['data', pId]))) { @@ -524,7 +522,7 @@ export function updateVertexInfo(markObj, plotId, dlObj) { exclusiveDef = {exclusiveOnDown: true, type: 'anywhere'}; vertexDef = {points: {[plotId]: []}, pointDist: {[plotId]: MARKER_DISTANCE}}; } else { - const cc = CsysConverter.make(primePlot(visRoot(), plotId)); + const cc = CsysConverter.make(currentP(plotId).plot); const {dist, centerPt} = getVertexDistance(markObj, cc); exclusiveDef = {exclusiveOnDown: true, type: 'vertexOnly'}; @@ -564,7 +562,7 @@ function createMarkerObjs(action, dl, plotId, wpt, size, prevRet, unitT) { text = get(dl, 'title', ''); // title is the default text by the footprint } - const cc = CsysConverter.make(primePlot(visRoot(), plotId)); + const cc = CsysConverter.make(currentP(plotId).plot); var [markerW, markerH] = isArray(size) && size.length > 1 ? [size[0], size[1]] : [size, size]; var markObj; @@ -617,7 +615,7 @@ function createMarkerObjs(action, dl, plotId, wpt, size, prevRet, unitT) { } } - if ([ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION, ImagePlotCntlr.ANY_REPLOT].includes(action.type) && + if ([CHANGE_CENTER_OF_PROJECTION, ANY_REPLOT].includes(action.type) && !markerStatus) { markerStatus = get(dl.drawData, [DataTypes.DATA, plotId, 'actionInfo', 'markerStatus'], MarkerStatus.select); } @@ -755,9 +753,9 @@ function attachToNewPlot(drawLayer, newPlotId) { get(drawLayer, ['drawData', 'data', existPlotId]); //const newPlotId = plotIdAry.find((pId) => isEmpty(data[pId])); - const existPlot = primePlot(visRoot(), existPlotId); + const {plot:existPlot} = currentP(existPlotId); const existCC = CsysConverter.make(existPlot); - const plot = primePlot(visRoot(), newPlotId); + const {plot} = currentP( newPlotId); const cc = CsysConverter.make(plot); //if (hasNoProjection(cc) !== hasNoProjection(existCC)) { diff --git a/src/firefly/js/drawingLayers/MarkerToolUI.jsx b/src/firefly/js/drawingLayers/MarkerToolUI.jsx index c033cef34f..567503126d 100644 --- a/src/firefly/js/drawingLayers/MarkerToolUI.jsx +++ b/src/firefly/js/drawingLayers/MarkerToolUI.jsx @@ -10,7 +10,8 @@ import {ListBoxInputFieldView} from '../ui/ListBoxInputField.jsx'; import {useStoreConnector} from '../ui/SimpleComponent.jsx'; import {TextLocation} from '../visualize/draw/DrawingDef.js'; import {flux} from '../core/ReduxFlux.js'; -import {dispatchModifyCustomField, DRAWING_LAYER_KEY} from '../visualize/DrawLayerCntlr.js'; +import {dispatchModifyCustomField} from '../visualize/DrawLayerDispatch'; +import {DRAWING_LAYER_KEY} from '../visualize/VisConst'; import {getDrawLayerById} from '../visualize/PlotViewUtil.js'; import {addNewDrawLayer} from '../visualize/ui/MarkerDropDownView.jsx'; diff --git a/src/firefly/js/drawingLayers/NorthUpCompass.js b/src/firefly/js/drawingLayers/NorthUpCompass.js index 31573311e3..99491f7fa6 100644 --- a/src/firefly/js/drawingLayers/NorthUpCompass.js +++ b/src/firefly/js/drawingLayers/NorthUpCompass.js @@ -2,47 +2,42 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import {get} from 'lodash'; -import ImagePlotCntlr, {visRoot} from '../visualize/ImagePlotCntlr.js'; +import {dispatchForceDrawLayerUpdate} from '../visualize/DrawLayerDispatch'; +import { + FLIP, FORCE_DRAW_LAYER_UPDATE, PROCESS_SCROLL, RECENTER, ROTATE, UPDATE_VIEW_SIZE, ZOOM_HIPS, ZOOM_IMAGE +} from '../visualize/VisConst'; import {makeDrawingDef} from '../visualize/draw/DrawingDef.js'; import DrawLayer, {ColorChangeType} from '../visualize/draw/DrawLayer.js'; import CsysConverter from '../visualize/CsysConverter.js'; +import {dlRoot} from '../visualize/VisStoreRoots'; import {getTopmostVisiblePoint} from '../visualize/WebPlotAnalysis'; import {makeWorldPt, makeScreenPt, makeDevicePt} from '../visualize/Point.js'; -import {primePlot, getPlotViewById} from '../visualize/PlotViewUtil.js'; +import {currentP} from '../visualize/PlotViewUtil.js'; import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js'; import {makeDirectionArrowDrawObj} from '../visualize/draw/DirectionArrowDrawObj.js'; import {getPixScaleDeg} from '../visualize/WebPlot.js'; -import DrawLayerCntlr, { dispatchForceDrawLayerUpdate} from '../visualize/DrawLayerCntlr.js'; import {CoordinateSys} from '../visualize/CoordSys.js'; import {getDrawLayerById, hasWCSProjection} from '../visualize/PlotViewUtil'; -import {dlRoot} from '../visualize/DrawLayerCntlr'; import {dispatchAddActionWatcher} from '../core/MasterSaga'; const ID= 'NORTH_UP_COMPASS_TOOL'; const TYPE_ID= 'NORTH_UP_COMPASS_TYPE'; - - const selHelpText='North Arrow - EQ. J2000'; + const factoryDef= makeFactoryDef(TYPE_ID,creator, getDrawData, null, null,/*getUIComponent*/null); export default {factoryDef, TYPE_ID}; // every draw layer must default export with factoryDef and TYPE_ID -var idCnt=0; - +let idCnt=0; -function relocateCompass(action, cancelSelf, {id}) { - const layer= getDrawLayerById(dlRoot(), id); - if (layer) dispatchForceDrawLayerUpdate(id, get(primePlot(visRoot()), 'plotId')); - else cancelSelf(); +function relocateCompass(action, cancelSelf, {drawLayerId}) { + const layer= getDrawLayerById(dlRoot(), drawLayerId); + layer ? dispatchForceDrawLayerUpdate(drawLayerId, currentP().plotId) : cancelSelf(); } - function creator() { - const drawingDef= makeDrawingDef('red'); - const actionTypes= [ImagePlotCntlr.UPDATE_VIEW_SIZE, - DrawLayerCntlr.FORCE_DRAW_LAYER_UPDATE]; + const actionTypes= [UPDATE_VIEW_SIZE, FORCE_DRAW_LAYER_UPDATE]; idCnt++; const options= { @@ -52,46 +47,37 @@ function creator() { destroyWhenAllDetached: false }; - const id = `${ID}-${idCnt}`; + const drawLayerId = `${ID}-${idCnt}`; dispatchAddActionWatcher({ callback:relocateCompass, - params: {id}, - actions:[ImagePlotCntlr.RECENTER, ImagePlotCntlr.PROCESS_SCROLL, ImagePlotCntlr.ZOOM_IMAGE, - ImagePlotCntlr.ZOOM_HIPS, ImagePlotCntlr.ROTATE, ImagePlotCntlr.FLIP] + params: {drawLayerId}, + actions:[RECENTER, PROCESS_SCROLL, ZOOM_IMAGE, ZOOM_HIPS, ROTATE, FLIP] }); - return DrawLayer.makeDrawLayer( id, TYPE_ID, selHelpText, - options, drawingDef, actionTypes); - + return DrawLayer.makeDrawLayer(drawLayerId, TYPE_ID, selHelpText, options, drawingDef, actionTypes); } - -function getDrawData(dataType, plotId, drawLayer, action, lastDataRet){ - const drawCompass = makeCompass(plotId, action, drawLayer); - return drawCompass || lastDataRet; +function getDrawData(dataType, plotId, drawLayer, action) { + return makeCompass(plotId, action, drawLayer); } function makeCompass(plotId){ - const plot= primePlot(visRoot(),plotId); - if (!plot) return null; - if (!hasWCSProjection(plot)) return null; - + const {pv,plot}= currentP(plotId); + if (!plot || !hasWCSProjection(plot)) return; const cc= CsysConverter.make(plot); - if (!cc) return null; - - const pv= getPlotViewById(visRoot(),plotId); + if (!cc) return; // const dist = 60; const px = 30; let sptStart= cc.getScreenCoords(getTopmostVisiblePoint(plot,pv.viewDim, 55, 120)); - if (!sptStart) return null; + if (!sptStart) return; let wpStart= cc.getWorldCoords(sptStart, CoordinateSys.EQ_J2000); if (!wpStart) { wpStart= cc.getWorldCoords( makeDevicePt(cc.viewDim.width/2, cc.viewDim.height/2), CoordinateSys.EQ_J2000); - if (!wpStart) return null; + if (!wpStart) return; sptStart= cc.getScreenCoords(wpStart); } @@ -104,8 +90,7 @@ function makeCompass(plotId){ const spt3= cc.getScreenCoords(wpt3); // don't use spt3 because of funny effects near the celestial poles // the sign of the cross product of compass vectors tells us if the image is mirror-reversed from the sky - const cross_product= (spt3.x - sptStart.x)*(spt2.y - sptStart.y) - - (spt3.y - sptStart.y)*(spt2.x - sptStart.x); + const cross_product= (spt3.x - sptStart.x)*(spt2.y - sptStart.y) - (spt3.y - sptStart.y)*(spt2.x - sptStart.x); const sptE2= getEastFromNorthOnScreen(cc, sptStart, spt2, Math.sign(cross_product)); if (!sptStart || !spt2 || !sptE2) return; @@ -113,16 +98,13 @@ function makeCompass(plotId){ const dataN= makeDirectionArrowDrawObj(sptStart, spt2,'N'); const dataE= makeDirectionArrowDrawObj(sptStart, sptE2,'E'); - return [dataE, dataN]; } function getEastFromNorthOnScreen(cc, origin, nVec, sign) { const originSpt = cc.getScreenCoords(origin); const vec1Spt = cc.getScreenCoords(nVec); - const x2 = sign*(vec1Spt.y - originSpt.y) + originSpt.x; const y2 = -sign*(vec1Spt.x - originSpt.x) + originSpt.y; - return makeScreenPt(x2, y2); } diff --git a/src/firefly/js/drawingLayers/PointSelection.js b/src/firefly/js/drawingLayers/PointSelection.js index 8f9f68eb37..05a4015745 100644 --- a/src/firefly/js/drawingLayers/PointSelection.js +++ b/src/firefly/js/drawingLayers/PointSelection.js @@ -3,9 +3,8 @@ */ -import DrawLayerCntlr from '../visualize/DrawLayerCntlr.js'; -import {visRoot,dispatchAttributeChange} from '../visualize/ImagePlotCntlr.js'; -import {primePlot, isActivePlotView} from '../visualize/PlotViewUtil.js'; +import {dispatchAttributeChange} from '../visualize/ImagePlotDispatch'; +import {currentP} from '../visualize/PlotViewUtil.js'; import {PlotAttribute} from '../visualize/PlotAttribute.js'; import PointDataObj from '../visualize/draw/PointDataObj.js'; import {DrawSymbol} from '../visualize/draw/DrawSymbol.js'; @@ -13,6 +12,7 @@ import {makeDrawingDef} from '../visualize/draw/DrawingDef.js'; import DrawLayer, {DataTypes,ColorChangeType} from '../visualize/draw/DrawLayer.js'; import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js'; import CsysConverter from '../visualize/CsysConverter.js'; +import {ATTACH_LAYER_TO_PLOT, CHANGE_DRAWING_DEF, SELECT_POINT} from '../visualize/VisConst'; import {MouseState} from '../visualize/VisMouseSync.js'; import {flux} from '../core/ReduxFlux.js'; import {clone} from '../util/WebUtil.js'; @@ -34,7 +34,7 @@ function dispatchSelectPoint(mouseStatePayload) { const {plotId,screenPt,drawLayer}= mouseStatePayload; if (mouseStatePayload.shiftDown) return; if (drawLayer.drawData.data) { - flux.process({type:DrawLayerCntlr.SELECT_POINT, payload:mouseStatePayload} ); + flux.process({type:SELECT_POINT, payload:mouseStatePayload} ); dispatchAttributeChange( {plotId, attKey:PlotAttribute.ACTIVE_POINT,attValue:{pt:makeSelectedPt(screenPt,plotId)} @@ -46,7 +46,7 @@ function dispatchSelectPoint(mouseStatePayload) { function onDetach(drawLayer,action) { const {plotIdAry}= action.payload; plotIdAry?.forEach( (plotId) => { - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); if (plot && plot.attributes[PlotAttribute.ACTIVE_POINT]) { dispatchAttributeChange( { plotId ,overlayColorScope:false,attKey:PlotAttribute.ACTIVE_POINT,attValue:null } @@ -67,7 +67,7 @@ function creator(initPayload, presetDefaults) { const pairs= { [MouseState.UP.key]: dispatchSelectPoint }; - const actionTypes= [DrawLayerCntlr.SELECT_POINT]; + const actionTypes= [SELECT_POINT]; const options = { isPointData: true, hasPerPlotData: true, @@ -83,26 +83,23 @@ function creator(initPayload, presetDefaults) { function getDrawData(dataType, plotId, drawLayer, action, lastDataRet) { if (dataType!==DataTypes.DATA) return null; - var active= isActivePlotView(visRoot(), plotId); - var drawAry= selectAPoint(drawLayer,action, active, plotId); + const active= currentP(plotId).active; + const drawAry= selectAPoint(drawLayer,action, active, plotId); return drawAry || lastDataRet; } function getLayerChanges(drawLayer, action) { - if (action.type===DrawLayerCntlr.CHANGE_DRAWING_DEF) { + if (action.type===CHANGE_DRAWING_DEF) { return {drawingDef: clone(drawLayer.drawingDef,action.payload.drawingDef)}; } } function makeSelectedPt(screenPt,plotId) { - var plot= primePlot(visRoot(),plotId); - var cc= CsysConverter.make(plot); - var selPt= cc.getWorldCoords(screenPt); //todo put back - - if (!selPt) selPt= cc.getImageCoords(screenPt); - return selPt; + const cc= CsysConverter.make(currentP(plotId).plot); + const selPt= cc.getWorldCoords(screenPt); //todo put back + return selPt ?? cc.getImageCoords(screenPt); } @@ -119,7 +116,7 @@ function selectAPoint(drawLayer, action, active, pId) { }; // attach drawing layer to the plot which is created after the drawing layer if (!screenPt && - action.type === DrawLayerCntlr.ATTACH_LAYER_TO_PLOT && + action.type === ATTACH_LAYER_TO_PLOT && !isEmptyData() && plotIdAry && plotIdAry.includes(pId)) { if (drawLayer.plotIdAry) { let dAry; diff --git a/src/firefly/js/drawingLayers/RegionPlot.js b/src/firefly/js/drawingLayers/RegionPlot.js index a74c71dc17..1477c0723b 100644 --- a/src/firefly/js/drawingLayers/RegionPlot.js +++ b/src/firefly/js/drawingLayers/RegionPlot.js @@ -6,18 +6,18 @@ import {flux} from '../core/ReduxFlux.js'; import {makeDrawingDef} from '../visualize/draw/DrawingDef.js'; import DrawLayer, {DataTypes, ColorChangeType} from '../visualize/draw/DrawLayer.js'; import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js'; +import {dispatchDeleteRegionLayer, dispatchSelectRegion} from '../visualize/DrawLayerDispatch'; import {drawRegions} from '../visualize/region/RegionDrawer.js'; import {getRegionIndex, addNewRegion, removeRegion} from '../visualize/region/RegionUtil.js'; import {RegionFactory} from '../visualize/region/RegionFactory.js'; -import {primePlot, getDrawLayerById, getDrawLayersByType} from '../visualize/PlotViewUtil.js'; -import {visRoot} from '../visualize/ImagePlotCntlr.js'; +import {currentP, getDrawLayerById, getDrawLayersByType} from '../visualize/PlotViewUtil.js'; +import { + DETACH_LAYER_FROM_PLOT, DRAWING_LAYER_KEY, REGION_ADD_ENTRY, REGION_DELETE_LAYER, REGION_REMOVE_ENTRY, REGION_SELECT +} from '../visualize/VisConst'; import {MouseState} from '../visualize/VisMouseSync.js'; import DrawOp from '../visualize/draw/DrawOp.js'; import {dispatchAddActionWatcher} from '../core/MasterSaga'; -import DrawLayerCntlr, {DRAWING_LAYER_KEY, - dispatchDeleteRegionLayer, - dispatchSelectRegion, - dlRoot, getDlAry} from '../visualize/DrawLayerCntlr.js'; +import {dlRoot, getDlAry} from '../visualize/VisStoreRoots'; const ID= 'REGION_PLOT'; const TYPE_ID= 'REGION_PLOT_TYPE'; @@ -28,12 +28,12 @@ function regionsRemoveWatcher(action, cancelSelf, params, dispatch, getState) { const {id, plotId}= params; if (action.payload.drawLayerId !== id) return params; switch (action.type) { - case DrawLayerCntlr.REGION_REMOVE_ENTRY : + case REGION_REMOVE_ENTRY : const dl = getDrawLayerById(getState()[DRAWING_LAYER_KEY], id); if (dl && isEmpty(dl?.drawObjAry)) dispatchDeleteRegionLayer(id, plotId); break; - case DrawLayerCntlr.REGION_DELETE_LAYER: - case DrawLayerCntlr.DETACH_LAYER_FROM_PLOT: + case REGION_DELETE_LAYER: + case DETACH_LAYER_FROM_PLOT: cancelSelf(); break; } @@ -104,9 +104,7 @@ function creator(initPayload) { destroyWhenAllDetached: true }; - const actionTypes = [DrawLayerCntlr.REGION_ADD_ENTRY, - DrawLayerCntlr.REGION_REMOVE_ENTRY, - DrawLayerCntlr.REGION_SELECT]; + const actionTypes = [REGION_ADD_ENTRY, REGION_REMOVE_ENTRY, REGION_SELECT]; const title = get(initPayload, 'title'); const id = initPayload.drawLayerId ? initPayload.drawLayerId : createNewRegionLayerId(); @@ -121,8 +119,7 @@ function creator(initPayload) { dispatchAddActionWatcher({ callback: regionsRemoveWatcher, params: {id, plotId: initPayload?.plotId}, - actions: [DrawLayerCntlr.REGION_REMOVE_ENTRY, - DrawLayerCntlr.REGION_DELETE_LAYER, DrawLayerCntlr.DETACH_LAYER_FROM_PLOT] + actions: [REGION_REMOVE_ENTRY, REGION_DELETE_LAYER, DETACH_LAYER_FROM_PLOT] }); return dl; } @@ -139,7 +136,7 @@ function highlightChange(mouseStatePayload) { var closestObj = null; const maxChunk = 1000; const {data} = drawLayer.drawData; - const plot = primePlot(visRoot(), plotId); + const {plot} = currentP(plotId); function* getDrawObj() { @@ -222,7 +219,7 @@ function getLayerChanges(drawLayer, action) { }; switch (action.type) { - case DrawLayerCntlr.REGION_SELECT: + case REGION_SELECT: const {selectedRegion} = action.payload; Object.keys(dd[DataTypes.HIGHLIGHT_DATA]).forEach((plotId) => { @@ -263,7 +260,7 @@ function getLayerChanges(drawLayer, action) { return Object.assign({}, {highlightedRegion}, {drawData: dd}, {selectRegionDesc}); - case DrawLayerCntlr.REGION_ADD_ENTRY: + case REGION_ADD_ENTRY: if (regionChanges) { var {layerTitle} = action.payload; @@ -279,7 +276,7 @@ function getLayerChanges(drawLayer, action) { } return {drawData: dd}; - case DrawLayerCntlr.REGION_REMOVE_ENTRY: + case REGION_REMOVE_ENTRY: if (regionChanges) { removeRegionsFromData(drawLayer, regionChanges); @@ -340,7 +337,7 @@ function plotHighlightRegion(highlightedObj, plotId, selectMode) { } if (highlightedObj.region) highlightedObj.region.highlighted = 1; - var hObj = [DrawOp.makeHighlight(highlightedObj, primePlot(visRoot(), plotId), selectMode)]; + var hObj = [DrawOp.makeHighlight(highlightedObj, currentP(plotId).plot, selectMode)]; hObj.forEach((oneObj) => { oneObj.highlight = 1; diff --git a/src/firefly/js/drawingLayers/SearchSelectTool.js b/src/firefly/js/drawingLayers/SearchSelectTool.js index 61ba9e7e70..c22639f3af 100644 --- a/src/firefly/js/drawingLayers/SearchSelectTool.js +++ b/src/firefly/js/drawingLayers/SearchSelectTool.js @@ -1,9 +1,11 @@ /* * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import DrawLayerCntlr, {dispatchForceDrawLayerUpdate} from '../visualize/DrawLayerCntlr.js'; -import {visRoot,dispatchAttributeChange} from '../visualize/ImagePlotCntlr.js'; -import {primePlot, isActivePlotView, getCenterOfProjection} from '../visualize/PlotViewUtil.js'; + +import {dispatchForceDrawLayerUpdate} from '../visualize/DrawLayerDispatch'; +import {CHANGE_DRAWING_DEF, MODIFY_CUSTOM_FIELD, SELECT_POINT} from '../visualize/VisConst'; +import {dispatchAttributeChange} from '../visualize/ImagePlotDispatch'; +import {getCenterOfProjection, currentP} from '../visualize/PlotViewUtil.js'; import {PlotAttribute} from '../visualize/PlotAttribute.js'; import PointDataObj from '../visualize/draw/PointDataObj.js'; import {DrawSymbol} from '../visualize/draw/DrawSymbol.js'; @@ -24,8 +26,6 @@ const TYPE_ID= 'SEARCH_SELECT_TOOL_TYPE'; const factoryDef= makeFactoryDef(TYPE_ID,creator,getDrawData,getLayerChanges,onDetach,null); const RADIUS= 'RADIUS'; -const DIAMETER= 'DIAMETER'; // todo - no yet implemented -const AREA= 'AREA'; // todo - no yet implemented export default {factoryDef, TYPE_ID}; // every draw layer must default export with factoryDef and TYPE_ID @@ -36,7 +36,7 @@ function dispatchSelectPoint(mouseStatePayload) { const {plotId,screenPt,drawLayer,shiftDown}= mouseStatePayload; if (!drawLayer.isInteractive) return; if (shiftDown || !drawLayer.drawData.data) return; - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); const cc= CsysConverter.make(plot); if (!plot) return; const wp= cc.getWorldCoords(screenPt); @@ -90,13 +90,13 @@ function dispatchSelectPoint(mouseStatePayload) { function saveLastDown(mouseStatePayload) { const {plotId}= mouseStatePayload; - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); lastProjectionCenter= {center:getCenterOfProjection(plot), plotId}; } function onDetach(drawLayer,action) { action.payload.plotIdAry?.forEach( (plotId) => { - if (primePlot(visRoot(),plotId)?.attributes[PlotAttribute.USER_SEARCH_WP]) return; + if (currentP(plotId).plot?.attributes[PlotAttribute.USER_SEARCH_WP]) return; dispatchAttributeChange({plotId, overlayColorScope:false, changes:{[PlotAttribute.USER_SEARCH_WP]:undefined}}); }); } @@ -109,7 +109,7 @@ function creator({minSize=1/3600,maxSize=100, searchType=RADIUS}={}, presetDefau [MouseState.DOWN.key]: saveLastDown // TODO: add events and listeners for interaction with rotation and resize handles }; - const actionTypes= [DrawLayerCntlr.SELECT_POINT]; + const actionTypes= [SELECT_POINT]; const options = { isPointData: false, hasPerPlotData: true, @@ -126,23 +126,23 @@ function creator({minSize=1/3600,maxSize=100, searchType=RADIUS}={}, presetDefau function getDrawData(dataType, plotId, drawLayer, action, lastDataRet) { if (dataType!==DataTypes.DATA) return undefined; - const active= isActivePlotView(visRoot(), plotId); + const {active}= currentP(plotId); const drawAry= drawSearchSelection(drawLayer,action, active, plotId); return drawAry || lastDataRet; } function getLayerChanges(drawLayer, action) { switch (action.type) { - case DrawLayerCntlr.CHANGE_DRAWING_DEF: + case CHANGE_DRAWING_DEF: return {drawingDef: {...drawLayer.drawingDef,...action.payload.drawingDef}}; - case DrawLayerCntlr.MODIFY_CUSTOM_FIELD: + case MODIFY_CUSTOM_FIELD: return {...action.payload.changes}; } } function drawSearchSelection(drawLayer, action, active, plotId) { const {plotIdAry}= action.payload; - const plot= primePlot(visRoot(),plotId||plotIdAry?.[0]); + const {plot}= currentP(plotId||plotIdAry?.[0]); if (!plot) return []; if (plot.attributes[PlotAttribute.USE_POLYGON]) return drawSearchSelectionPolygon(plot, drawLayer); if (plot.attributes[PlotAttribute.USE_BOX]) return drawSearchSelectionTransformBox(plot, drawLayer); @@ -182,7 +182,7 @@ function drawSearchSelectionPolygon(plot, drawLayer) { {...ShapeDataObj.makePolygon(wpAry), lineWidth:1, renderOptions:{lineDash:[5,5]}}]; // locked layer } -function drawSearchSelectionTransformBox(plot, drawLayer) { +function drawSearchSelectionTransformBox(plot) { const wp= plot.attributes[PlotAttribute.USER_SEARCH_WP]; // const box = plot.attributes[PlotAttribute.USER_SEARCH_BOX]; const wpAry = plot?.attributes[PlotAttribute.POLYGON_ARY]; diff --git a/src/firefly/js/drawingLayers/SearchTarget.js b/src/firefly/js/drawingLayers/SearchTarget.js index 3235c75ac8..a471945931 100644 --- a/src/firefly/js/drawingLayers/SearchTarget.js +++ b/src/firefly/js/drawingLayers/SearchTarget.js @@ -11,14 +11,13 @@ import {DrawSymbol} from '../visualize/draw/DrawSymbol.js'; import {getNextColor, makeDrawingDef, releaseColor} from '../visualize/draw/DrawingDef.js'; import DrawLayer, {DataTypes,ColorChangeType} from '../visualize/draw/DrawLayer.js'; import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js'; -import {getActivePlotView, getPlotViewById, primePlot} from '../visualize/PlotViewUtil'; -import ImagePlotCntlr, {visRoot} from '../visualize/ImagePlotCntlr'; +import {currentP} from '../visualize/PlotViewUtil'; +import {CHANGE_DRAWING_DEF, MODIFY_CUSTOM_FIELD, RECENTER} from '../visualize/VisConst'; import {PlotAttribute} from '../visualize/PlotAttribute.js'; import {formatWorldPt} from '../visualize/ui/WorldPtFormat.jsx'; import {flux} from 'firefly/core/ReduxFlux.js'; import Point from 'firefly/visualize/Point.js'; import CsysConverter from 'firefly/visualize/CsysConverter.js'; -import DrawLayerCntlr from 'firefly/visualize/DrawLayerCntlr.js'; import {FixedPtControl} from './FixedPtControl.jsx'; const ID= 'SEARCH_TARGET'; @@ -55,7 +54,7 @@ function creator(initPayload, presetDefaults) { canUserDelete, allocatedColor: !Boolean(color), }; - return DrawLayer.makeDrawLayer(drawLayerId || `${ID}-${idCnt}`,TYPE_ID, {}, options, drawingDef, [ImagePlotCntlr.RECENTER, UPDATE_SEARCH_TARGET]); + return DrawLayer.makeDrawLayer(drawLayerId || `${ID}-${idCnt}`,TYPE_ID, {}, options, drawingDef, [RECENTER, UPDATE_SEARCH_TARGET]); } function layerRemoved(drawLayer,action) { @@ -64,30 +63,25 @@ function layerRemoved(drawLayer,action) { function getLayerChanges(drawLayer, action) { const {plotId}= drawLayer; - let pv; - let plot; - if (plotId) { - pv= getPlotViewById(visRoot(),plotId); - plot= primePlot(pv); - } + const {pv, plot}= currentP(plotId); let drawData= drawLayer.drawData; let drawingDef= drawLayer.drawingDef; switch (action.type) { - case ImagePlotCntlr.RECENTER : + case RECENTER : setTimeout(() => flux.process({ type: UPDATE_SEARCH_TARGET, payload: {plotId}}), 1); drawData= drawLayer.drawData; break; - case ImagePlotCntlr.UPDATE_SEARCH_TARGET: + case UPDATE_SEARCH_TARGET: drawData= undefined; break; - case DrawLayerCntlr.MODIFY_CUSTOM_FIELD: + case MODIFY_CUSTOM_FIELD: const {changes}= action.payload; drawData= undefined; if (changes.color) { drawingDef= {...drawingDef,color:changes.color}; } break; - case DrawLayerCntlr.CHANGE_DRAWING_DEF: + case CHANGE_DRAWING_DEF: drawingDef= action.payload.drawingDef; drawingDef.preferedColor= drawingDef.color; drawData= computeDrawData({...drawLayer,drawingDef}); @@ -105,7 +99,7 @@ function getDrawData(dataType, plotId, drawLayer, action, lastDataRet) { function getTitle(pv, plot, dl) { const pt= dl.searchTargetPoint || plot?.attributes?.[PlotAttribute.FIXED_TARGET]; if (!pt) return null; - if (!pv) pv= getActivePlotView(visRoot()); + if (!pv) pv= currentP().pv; let ptDiv; let minWidth; @@ -146,7 +140,7 @@ function getTitle(pv, plot, dl) { function computeDrawData(drawLayer) { const {plotId}= drawLayer; - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); let wp= drawLayer.searchTargetPoint; if (!wp && plot) { if (!plot) return []; diff --git a/src/firefly/js/drawingLayers/SelectArea.js b/src/firefly/js/drawingLayers/SelectArea.js index 76475c7c0f..ec48f196cf 100644 --- a/src/firefly/js/drawingLayers/SelectArea.js +++ b/src/firefly/js/drawingLayers/SelectArea.js @@ -3,8 +3,11 @@ */ import {get, isEmpty} from 'lodash'; import Enum from 'enum'; -import DrawLayerCntlr, {DRAWING_LAYER_KEY} from '../visualize/DrawLayerCntlr.js'; -import ImagePlotCntlr, {dispatchAttributeChange, visRoot} from '../visualize/ImagePlotCntlr.js'; +import {dispatchAttributeChange} from '../visualize/ImagePlotDispatch'; +import { + ATTACH_LAYER_TO_PLOT, CHANGE_HIPS, DRAWING_LAYER_KEY, SELECT_AREA_END, SELECT_AREA_MOVE, SELECT_AREA_START, + SELECT_MOUSE_LOC +} from '../visualize/VisConst'; import {makeDrawingDef, Style} from '../visualize/draw/DrawingDef.js'; import DrawLayer, {ColorChangeType} from '../visualize/draw/DrawLayer.js'; import {closeToolbarModalLayers} from '../visualize/ui/ToolbarToolModalEnd'; @@ -17,7 +20,7 @@ import {computeScreenDistance, getBoundingBox} from '../visualize/VisUtil.js'; import SelectBox from '../visualize/draw/SelectBox.js'; import FootPrintObj from '../visualize/draw/FootprintObj.js'; import ShapeDataObj from '../visualize/draw/ShapeDataObj.js'; -import {getDrawLayerById, getPlotViewById, hasWCSProjection, primePlot} from '../visualize/PlotViewUtil.js'; +import { currentP, getDrawLayerById, hasWCSProjection, primePlot} from '../visualize/PlotViewUtil.js'; import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js'; import {SelectedShape} from './SelectedShape'; @@ -47,10 +50,8 @@ export function selectAreaEndActionCreator(rawAction) { return (dispatcher, getState) => { const {plotId}= rawAction.payload; let {drawLayer}= rawAction.payload; - const pv= getPlotViewById(visRoot(),plotId); - const plot= primePlot(pv); - dispatcher({type:DrawLayerCntlr.SELECT_AREA_END, payload:rawAction.payload} ); - + const {pv,plot}= currentP(plotId); + dispatcher({type:SELECT_AREA_END, payload:rawAction.payload} ); drawLayer= getDrawLayerById(getState()[DRAWING_LAYER_KEY], drawLayer.drawLayerId); if (drawLayer.drawData.data) { @@ -76,16 +77,13 @@ function creator(initPayload) { const drawingDef= makeDrawingDef('black'); const pairs= { - [MouseState.MOVE.key]: DrawLayerCntlr.SELECT_MOUSE_LOC, - [MouseState.DRAG.key]: DrawLayerCntlr.SELECT_AREA_MOVE, - [MouseState.DOWN.key]: DrawLayerCntlr.SELECT_AREA_START, - [MouseState.UP.key]: DrawLayerCntlr.SELECT_AREA_END + [MouseState.MOVE.key]: SELECT_MOUSE_LOC, + [MouseState.DRAG.key]: SELECT_AREA_MOVE, + [MouseState.DOWN.key]: SELECT_AREA_START, + [MouseState.UP.key]: SELECT_AREA_END }; - const actionTypes= [DrawLayerCntlr.SELECT_AREA_START, - DrawLayerCntlr.SELECT_AREA_MOVE, - DrawLayerCntlr.SELECT_AREA_END, - DrawLayerCntlr.SELECT_MOUSE_LOC]; + const actionTypes= [SELECT_AREA_START, SELECT_AREA_MOVE, SELECT_AREA_END, SELECT_MOUSE_LOC]; const exclusiveDef= { exclusiveOnDown: true, type : 'anywhere' }; @@ -108,7 +106,7 @@ function creator(initPayload) { function onDetach(drawLayer,action) { action.payload.plotIdAry.forEach( (plotId) => { - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); if (plot?.attributes[PlotAttribute.SELECTION]) { dispatchAttributeChange({plotId,overlayColorScope:false, changes: { @@ -146,20 +144,20 @@ function getCursor(plotView, screenPt) { function getLayerChanges(drawLayer, action) { switch (action.type) { - case DrawLayerCntlr.SELECT_AREA_START: + case SELECT_AREA_START: return start(drawLayer,action); - case DrawLayerCntlr.SELECT_AREA_MOVE: + case SELECT_AREA_MOVE: return drag(drawLayer,action); - case DrawLayerCntlr.SELECT_AREA_END: + case SELECT_AREA_END: return end(drawLayer,action); - case DrawLayerCntlr.ATTACH_LAYER_TO_PLOT: + case ATTACH_LAYER_TO_PLOT: if (isEmpty(get(drawLayer, ['drawData', 'data']))) { return attach(); } break; - case DrawLayerCntlr.SELECT_MOUSE_LOC: + case SELECT_MOUSE_LOC: return moveMouse(drawLayer,action); - case ImagePlotCntlr.CHANGE_HIPS: + case CHANGE_HIPS: if (action.payload.coordSys) { setTimeout(() => closeToolbarModalLayers(),4); } @@ -181,7 +179,7 @@ function attach() { function moveMouse(drawLayer,action) { const {screenPt,plotId}= action.payload; - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); const mode= getMode(plot); if (plot && mode==='edit') { const cc= CsysConverter.make(plot); @@ -206,7 +204,7 @@ function moveMouse(drawLayer,action) { function start(drawLayer,action) { const {screenPt,imagePt,plotId,shiftDown}= action.payload; - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); const mode= getMode(plot); if (!plot) return; @@ -268,8 +266,7 @@ function getPtAryForCorners(plot,pt0,pt1) { function drag(drawLayer,action) { const {imagePt,plotId}= action.payload; - const pv= getPlotViewById(visRoot(),plotId); - const plot= primePlot(pv); + const {pv,plot}= currentP(plotId); if (!plot) return; const drawSel= makeSelectObj(drawLayer.originalCenterPt, drawLayer.firstPt, imagePt, plot, pv.rotation, plot.title, drawLayer); const exclusiveDef= { exclusiveOnDown: true, type : 'vertexThenAnywhere' }; @@ -281,7 +278,7 @@ function drag(drawLayer,action) { } function end(drawLayer,action) { - const mode= getMode(primePlot(visRoot(),action.payload.plotId)); + const mode= getMode(currentP(action.payload.plotId).plot); return (mode==='select') ? {helpLine: editHelpText} : {}; } diff --git a/src/firefly/js/drawingLayers/StatsPoint.js b/src/firefly/js/drawingLayers/StatsPoint.js index f6c4d6908f..6cb5d3db4f 100644 --- a/src/firefly/js/drawingLayers/StatsPoint.js +++ b/src/firefly/js/drawingLayers/StatsPoint.js @@ -3,12 +3,11 @@ */ -import ImagePlotCntlr from '../visualize/ImagePlotCntlr.js'; -import DrawLayerCntlr from '../visualize/DrawLayerCntlr.js'; import PointDataObj from '../visualize/draw/PointDataObj.js'; import {makeDrawingDef} from '../visualize/draw/DrawingDef.js'; import DrawLayer, {DataTypes,ColorChangeType} from '../visualize/draw/DrawLayer.js'; import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js'; +import {MODIFY_CUSTOM_FIELD} from '../visualize/VisConst'; const ID= 'STATS_POINT'; const TYPE_ID= 'STATS_POINT_TYPE'; @@ -38,7 +37,7 @@ function creator(initPayload) { function getLayerChanges(drawLayer, action) { switch (action.type) { - case DrawLayerCntlr.MODIFY_CUSTOM_FIELD: + case MODIFY_CUSTOM_FIELD: let drawData = {}; const {changes} = action.payload; diff --git a/src/firefly/js/drawingLayers/WebGrid.js b/src/firefly/js/drawingLayers/WebGrid.js index d2b0402e96..b959b3d7a5 100644 --- a/src/firefly/js/drawingLayers/WebGrid.js +++ b/src/firefly/js/drawingLayers/WebGrid.js @@ -5,18 +5,17 @@ */ -import {get, isBoolean} from 'lodash'; +import {isBoolean} from 'lodash'; import {clone, isDefined} from '../util/WebUtil.js'; -import ImagePlotCntlr, {visRoot} from '../visualize/ImagePlotCntlr.js'; + import {ANY_REPLOT, CHANGE_CENTER_OF_PROJECTION, MODIFY_CUSTOM_FIELD, UPDATE_VIEW_SIZE} from '../visualize/VisConst'; import {makeDrawingDef} from '../visualize/draw/DrawingDef.js'; import DrawLayer, {ColorChangeType} from '../visualize/draw/DrawLayer.js'; import CsysConverter from '../visualize/CsysConverter.js'; -import {primePlot} from '../visualize/PlotViewUtil.js'; +import {currentP} from '../visualize/PlotViewUtil.js'; import {makeFactoryDef} from '../visualize/draw/DrawLayerFactory.js'; import {getUIComponent} from './WebGridUI.jsx'; import { makeGridDrawData } from './ComputeWebGridData.js'; import {changeHiPSProjectionCenterAndType, isHiPSAitoff, isImage} from '../visualize/WebPlot.js'; -import DrawLayerCntlr from '../visualize/DrawLayerCntlr.js'; import {getPreference} from '../core/AppDataCntlr.js'; import {flux} from '../core/ReduxFlux.js'; import CoordinateSys from '../visualize/CoordSys.js'; @@ -66,7 +65,7 @@ function creator(params) { destroyWhenAllUserDetached: true, }; - return DrawLayer.makeDrawLayer( id, TYPE_ID, 'Coordinate Grid', options , drawingDef, [ImagePlotCntlr.UPDATE_VIEW_SIZE, UPDATE_GRID ]); + return DrawLayer.makeDrawLayer( id, TYPE_ID, 'Coordinate Grid', options , drawingDef, [UPDATE_VIEW_SIZE, UPDATE_GRID ]); } /** @@ -81,10 +80,10 @@ function creator(params) { function getDrawData(dataType, plotId, drawLayer, action, lastDataRet){ - var plot= primePlot(visRoot(),plotId); + let {plot}= currentP(plotId); if (!plot)return null; - const projectionTypeChange= action.type===ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION && isDefined(action.payload.fullSky); + const projectionTypeChange= action.type===CHANGE_CENTER_OF_PROJECTION && isDefined(action.payload.fullSky); if (projectionTypeChange) { let aitoff= isHiPSAitoff(plot); aitoff= !aitoff; @@ -107,7 +106,7 @@ function getDrawData(dataType, plotId, drawLayer, action, lastDataRet){ function getLayerChanges(drawLayer, action) { let drawData; switch (action.type){ - case ImagePlotCntlr.ANY_REPLOT: + case ANY_REPLOT: if (drawLayer.drawData?.data ) { if (action.payload.plotIdAry){ const data= clone(drawLayer.drawData.data); @@ -120,23 +119,23 @@ function getDrawData(dataType, plotId, drawLayer, action, lastDataRet){ return {drawData}; } break; - case ImagePlotCntlr.UPDATE_VIEW_SIZE: + case UPDATE_VIEW_SIZE: setTimeout(() => { flux.process({ type: UPDATE_GRID, payload: { plotId: action.payload.plotId}}); }); break; case UPDATE_GRID: - case ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION: + case CHANGE_CENTER_OF_PROJECTION: if (drawLayer.drawData?.data ) { const data = Object.keys(drawLayer.drawData.data).reduce((d, plotId) => { - d[plotId] = isImage(primePlot(visRoot(), plotId)) ? drawLayer.drawData.data[plotId] : null; + d[plotId] = isImage(currentP(plotId).plot) ? drawLayer.drawData.data[plotId] : null; return d; }, {}); drawData= Object.assign({},drawLayer.drawData, {data}); return {drawData}; } break; - case DrawLayerCntlr.MODIFY_CUSTOM_FIELD: + case MODIFY_CUSTOM_FIELD: const {coordinate}= action.payload.changes; if (coordinate !== drawLayer.coordinate ) { const drawData= Object.assign({},drawLayer.drawData, {data:null}); @@ -171,7 +170,7 @@ function getDrawData(dataType, plotId, drawLayer, action, lastDataRet){ function getCoordinateSystem(csysName) { for (let i = 0; i < coordinateArray.length; i += 1) { - if (get(coordinateArray[i], 'coordName') === csysName) { + if (coordinateArray[i]?.coordName === csysName) { return coordinateArray[i].csys; } diff --git a/src/firefly/js/drawingLayers/WebGridUI.jsx b/src/firefly/js/drawingLayers/WebGridUI.jsx index 45ce1e346d..a67920ef66 100644 --- a/src/firefly/js/drawingLayers/WebGridUI.jsx +++ b/src/firefly/js/drawingLayers/WebGridUI.jsx @@ -5,7 +5,7 @@ */ import React from 'react'; import {object} from 'prop-types'; -import {dispatchModifyCustomField} from '../visualize/DrawLayerCntlr.js'; +import {dispatchModifyCustomField} from '../visualize/DrawLayerDispatch'; import {dispatchAddPreference,getPreference} from '../core/AppDataCntlr.js'; import {ListBoxInputFieldView} from '../ui/ListBoxInputField.jsx'; import {COORDINATE_PREFERENCE} from './WebGrid.js'; diff --git a/src/firefly/js/drawingLayers/hpx/HpxCatalog.js b/src/firefly/js/drawingLayers/hpx/HpxCatalog.js index 2a755af2c0..24c67e04b9 100644 --- a/src/firefly/js/drawingLayers/hpx/HpxCatalog.js +++ b/src/firefly/js/drawingLayers/hpx/HpxCatalog.js @@ -18,11 +18,16 @@ import DrawOp from '../../visualize/draw/DrawOp'; import {DrawSymbol} from '../../visualize/draw/DrawSymbol'; import DrawUtil from '../../visualize/draw/DrawUtil'; import PointDataObj from '../../visualize/draw/PointDataObj'; -import DrawLayerCntlr, { - dispatchForceDrawLayerUpdate, dispatchModifyCustomField, dispatchUpdateDrawLayer, dlRoot, getDlAry, SUBGROUP -} from '../../visualize/DrawLayerCntlr'; -import ImagePlotCntlr, {dispatchUseTableAutoScroll, visRoot} from '../../visualize/ImagePlotCntlr'; -import {dispatchBottomUIComponent, findViewerWithItemId, getMultiViewRoot, IMAGE} from '../../visualize/MultiViewCntlr'; +import { + dispatchForceDrawLayerUpdate, dispatchModifyCustomField, dispatchUpdateDrawLayer +} from '../../visualize/DrawLayerDispatch'; +import {dlRoot, getDlAry, visRoot} from '../../visualize/VisStoreRoots'; +import { + ANY_REPLOT, ATTACH_LAYER_TO_PLOT, CHANGE_CENTER_OF_PROJECTION, CHANGE_DRAWING_DEF, CHANGE_HIPS, ZOOM_IMAGE, + DESTROY_DRAWING_LAYER, IMAGE, MODIFY_CUSTOM_FIELD, PROCESS_SCROLL, RECENTER, SUBGROUP, UPDATE_VIEW_SIZE, +} from '../../visualize/VisConst'; +import {dispatchUseTableAutoScroll} from '../../visualize/ImagePlotDispatch'; +import {dispatchBottomUIComponent, findViewerWithItemId, getMultiViewRoot} from '../../visualize/MultiViewCntlr'; import {PlotAttribute} from '../../visualize/PlotAttribute'; import { getCenterOfProjection, getConnectedPlotsIds, getDrawLayerById, getPlotViewIdListByPositionLock, primePlot @@ -40,10 +45,7 @@ import { } from './HpxCatalogUtil'; import {createTileDataMaker} from './TileDataMaker'; -const getLayerActions= () => [ - DrawLayerCntlr.ATTACH_LAYER_TO_PLOT, DrawLayerCntlr.DESTROY_DRAWING_LAYER, - DrawLayerCntlr.MODIFY_CUSTOM_FIELD, DrawLayerCntlr.CHANGE_DRAWING_DEF -]; +const getLayerActions= () => [ ATTACH_LAYER_TO_PLOT, DESTROY_DRAWING_LAYER, MODIFY_CUSTOM_FIELD, CHANGE_DRAWING_DEF ]; const getTableActions= () => [ TABLE_HIGHLIGHT,TABLE_UPDATE, TABLE_SELECT ]; @@ -96,9 +98,7 @@ function creator(initPayload, presetDefaults={}) { dispatchAddActionWatcher({ actions:[ ...getLayerActions(), ...getTableActions(), - ImagePlotCntlr.ANY_REPLOT, - ImagePlotCntlr.ZOOM_IMAGE, ImagePlotCntlr.RECENTER, ImagePlotCntlr.PROCESS_SCROLL, - ImagePlotCntlr.CHANGE_HIPS, ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION, ImagePlotCntlr.UPDATE_VIEW_SIZE, + ANY_REPLOT, ZOOM_IMAGE, RECENTER, PROCESS_SCROLL, CHANGE_HIPS, CHANGE_CENTER_OF_PROJECTION, UPDATE_VIEW_SIZE, ], callback: watchDisplay, params: {tbl_id,catalogId} @@ -267,7 +267,7 @@ function getMaxExpandedTiles(norder,tbl_id,ipixAry) { } function getLayerChanges(drawLayer, action) { - if (action.type!==DrawLayerCntlr.MODIFY_CUSTOM_FIELD) return null; + if (action.type!==MODIFY_CUSTOM_FIELD) return null; const {changes}= action.payload; return changes; } @@ -276,7 +276,7 @@ function getLayerChanges(drawLayer, action) { -function getDrawData(dataType, plotId, drawLayer, action, lastDataRet) { +function getDrawData(dataType, plotId, drawLayer) { switch (dataType) { case DataTypes.DATA: return drawLayer.drawData?.data?.[plotId]; @@ -317,17 +317,16 @@ function handleLayerActions(action,cancelSelf,params) { if (action.payload.drawLayerId !== catalogId) return; const dl = getDrawLayerById(getDlAry(), catalogId); switch (action.type) { - case DrawLayerCntlr.ATTACH_LAYER_TO_PLOT: + case ATTACH_LAYER_TO_PLOT: action.payload.plotIdAry.forEach((plotId) => void makeTileDataAndUpdate(dl, plotId, tbl_id)); break; - case DrawLayerCntlr.CHANGE_DRAWING_DEF: + case CHANGE_DRAWING_DEF: dl?.visiblePlotIdAry?.forEach((plotId) => void makeTileDataAndUpdate(dl, plotId, tbl_id, false)); break; - case DrawLayerCntlr.MODIFY_CUSTOM_FIELD: + case MODIFY_CUSTOM_FIELD: dl?.visiblePlotIdAry?.forEach((plotId) => void makeTileDataAndUpdate(dl, plotId, tbl_id, false)); break; - - case DrawLayerCntlr.DESTROY_DRAWING_LAYER: + case DESTROY_DRAWING_LAYER: case TABLE_REMOVE: cancelSelf(); break; @@ -363,28 +362,28 @@ function handlePlotActions(action, cancelSelf, params) { const plot= plotId && primePlot(visRoot(),plotId); switch (action.type) { - case ImagePlotCntlr.ZOOM_IMAGE: - case ImagePlotCntlr.PROCESS_SCROLL: + case ZOOM_IMAGE: + case PROCESS_SCROLL: const plotIdAry= getPlotViewIdListByPositionLock(visRoot(),plotId); plotIdAry.forEach( (plotId) => { const plot= primePlot(visRoot(),plotId); if (!isImage(plot) || !connectedIds.includes(plotId)) return; - void makeTileDataAndUpdate(dl,plotId,tbl_id, action.type!==ImagePlotCntlr.PROCESS_SCROLL); + void makeTileDataAndUpdate(dl,plotId,tbl_id, action.type!==PROCESS_SCROLL); }); break; - case ImagePlotCntlr.UPDATE_VIEW_SIZE: - case ImagePlotCntlr.RECENTER: + case UPDATE_VIEW_SIZE: + case RECENTER: if (!connectedIds.includes(plotId)) return; - void makeTileDataAndUpdate(dl,plotId,tbl_id, action.type!==ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION); + void makeTileDataAndUpdate(dl,plotId,tbl_id, action.type!==CHANGE_CENTER_OF_PROJECTION); break; - case ImagePlotCntlr.ANY_REPLOT: - case ImagePlotCntlr.CHANGE_HIPS: - case ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION: + case ANY_REPLOT: + case CHANGE_HIPS: + case CHANGE_CENTER_OF_PROJECTION: if (!isHiPS(plot)) return; if (!connectedIds.includes(plotId)) return; - void makeTileDataAndUpdate(dl,plotId,tbl_id, action.type!==ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION); + void makeTileDataAndUpdate(dl,plotId,tbl_id, action.type!==CHANGE_CENTER_OF_PROJECTION); break; } return params; diff --git a/src/firefly/js/drawingLayers/hpx/HpxCatalogUtil.js b/src/firefly/js/drawingLayers/hpx/HpxCatalogUtil.js index 22e5a2ff96..11eb4d5fd1 100644 --- a/src/firefly/js/drawingLayers/hpx/HpxCatalogUtil.js +++ b/src/firefly/js/drawingLayers/hpx/HpxCatalogUtil.js @@ -2,7 +2,7 @@ import pointInPolygon from 'point-in-polygon'; import {dispatchAddWorkingTask} from '../../core/AppDataCntlr'; import {FilterInfo} from '../../tables/FilterInfo'; import { - DATA_NORDER, ensureDataForSelection, getAllWptsIdxsForTile, getHpxIndexData, getValuesForOrder, HPX_WORKING_KEY, + DATA_NORDER, ensureDataForSelection, getAllWptsIdxsForTile, getHpxIndexData, getValuesForOrder, } from '../../tables/HpxIndexCntlr'; import {SelectInfo} from '../../tables/SelectInfo'; import {dispatchTableFilter, dispatchTableSelect} from '../../tables/TablesCntlr'; @@ -12,10 +12,11 @@ import BrowserInfo from '../../util/BrowserInfo'; import {callWhileAwaiting} from '../../util/WebUtil'; import CoordSys from '../../visualize/CoordSys'; import CysConverter from '../../visualize/CsysConverter'; -import {dlRoot} from '../../visualize/DrawLayerCntlr'; +import {dlRoot} from '../../visualize/VisStoreRoots'; import {getCatalogNorderlevel, getCornersForCell} from '../../visualize/HiPSUtil'; import {PlotAttribute} from '../../visualize/PlotAttribute'; -import {DEFAULT_COVERAGE_PLOT_ID, getAllDrawLayersForPlot, primePlot} from '../../visualize/PlotViewUtil'; +import {getAllDrawLayersForPlot, primePlot} from '../../visualize/PlotViewUtil'; +import {DEFAULT_COVERAGE_PLOT_ID} from '../../visualize/VisConst'; import {detachSelectArea} from '../../visualize/ui/SelectAreaUIComponents'; import {contains, containsEllipse} from '../../visualize/VisUtil'; import SelectArea from '../SelectArea'; diff --git a/src/firefly/js/drawingLayers/hpx/TileDataMaker.jsx b/src/firefly/js/drawingLayers/hpx/TileDataMaker.jsx index f8eed9efbd..cbf0d6b7ec 100644 --- a/src/firefly/js/drawingLayers/hpx/TileDataMaker.jsx +++ b/src/firefly/js/drawingLayers/hpx/TileDataMaker.jsx @@ -10,7 +10,7 @@ import {getTblById} from '../../tables/TableUtil'; import CoordSys from '../../visualize/CoordSys'; import CysConverter from '../../visualize/CsysConverter'; import {getAllVisibleHiPSCells, getCatalogNorderlevel, getPointMaxSide} from '../../visualize/HiPSUtil'; -import {visRoot} from '../../visualize/ImagePlotCntlr'; +import {visRoot} from '../../visualize/VisStoreRoots'; import {getFoV, primePlot} from '../../visualize/PlotViewUtil'; import {isHiPSAitoff} from '../../visualize/WebPlot'; import {BOX_GROUP_TYPE, getHeatMapNorder, HEAT_MAP_GROUP_TYPE, HPX_GRID_SIZE_LARGE} from './HpxCatalogUtil'; @@ -25,7 +25,7 @@ const MAX_SYNC_AREA = 1_000_000; * @param obj.plotId * @param obj.tbl_id * @param obj.expanded - * @return {{abort: function, makeTileData, hasPartialTileUpdate, getSecondaryPartialTileUpdate} + * @return {{abort: function, makeTileData, hasPartialTileUpdate, getSecondaryPartialTileUpdate}} */ export function createTileDataMaker({drawLayer, plotId, tbl_id, expanded={}}) { let doAbort = false; @@ -82,7 +82,7 @@ const doMakeTileDataSync = ({cells, ...tileDataParams}) => { let plotData = []; if (!cells) return plotData; for (let index = 0; index < cells.length; index++) { - const {drawObjs,missingCells} = getDrawDataForCell({cell: cells[index], ...tileDataParams}); + const {drawObjs} = getDrawDataForCell({cell: cells[index], ...tileDataParams}); plotData= addTo(plotData,drawObjs); } return plotData; @@ -105,7 +105,7 @@ function doMakeTileDataInterval(isAborted, {resolve, cells, ...tileDataParams}) return; } for (; index < length;) { - const {drawObjs, missingCells} = getDrawDataForCell({cell: cells[index], ...tileDataParams}); + const {drawObjs} = getDrawDataForCell({cell: cells[index], ...tileDataParams}); plotData= addTo(plotData,drawObjs); index++; if (drawObjs.length > 300) return; @@ -114,7 +114,7 @@ function doMakeTileDataInterval(isAborted, {resolve, cells, ...tileDataParams}) resolve(plotData); } ); -}; +} function setupTileDataParams(drawLayer, table, plot, expanded) { diff --git a/src/firefly/js/fieldGroup/FieldGroupCntlr.js b/src/firefly/js/fieldGroup/FieldGroupCntlr.js index 5907a0c517..6992eb0b60 100644 --- a/src/firefly/js/fieldGroup/FieldGroupCntlr.js +++ b/src/firefly/js/fieldGroup/FieldGroupCntlr.js @@ -5,7 +5,7 @@ import {flux} from '../core/ReduxFlux.js'; import {isEqual, isUndefined} from 'lodash'; import {revalidateFields} from './FieldGroupUtils.js'; -import {REINIT_APP} from '../core/AppDataCntlr.js'; +import {REINIT_APP} from '../core/CoreConst'; import {isDefined} from 'firefly/util/WebUtil.js'; /** diff --git a/src/firefly/js/metaConvert/DataProductsCntlr.js b/src/firefly/js/metaConvert/DataProductsCntlr.js index 93e3db29c7..2442def655 100644 --- a/src/firefly/js/metaConvert/DataProductsCntlr.js +++ b/src/firefly/js/metaConvert/DataProductsCntlr.js @@ -1,5 +1,5 @@ import {get, isArray, isObject} from 'lodash'; -import {REINIT_APP} from '../core/AppDataCntlr'; +import {REINIT_APP} from '../core/CoreConst'; import {flux} from '../core/ReduxFlux'; import {download} from '../util/fetch'; import {encodeUrl, getRootURL} from '../util/WebUtil'; diff --git a/src/firefly/js/metaConvert/DataProductsFactory.js b/src/firefly/js/metaConvert/DataProductsFactory.js index b70eb519ab..44c7772c2b 100644 --- a/src/firefly/js/metaConvert/DataProductsFactory.js +++ b/src/firefly/js/metaConvert/DataProductsFactory.js @@ -8,7 +8,8 @@ import {getMetaEntry, getObjectMetaEntry} from '../tables/TableUtil'; import {getDataServiceOptionByTable} from '../ui/tap/DataServicesOptions'; import {toBoolean} from '../util/WebUtil'; import {Band} from '../visualize/Band'; -import {SINGLE} from '../visualize/MultiViewCntlr'; + +import {SINGLE} from '../visualize/VisConst'; import {hasObsCoreLikeDataProducts, isDatalinkTable} from '../voAnalyzer/TableAnalysis.js'; import {hasServiceDescriptors} from '../voAnalyzer/VoDataLinkServDef.js'; import {makeAnalysisGetGridDataProduct, makeAnalysisGetSingleDataProduct} from './AnalysisUtils.js'; diff --git a/src/firefly/js/metaConvert/DataProductsWatcher.js b/src/firefly/js/metaConvert/DataProductsWatcher.js index a0aa8db349..de9cc61780 100644 --- a/src/firefly/js/metaConvert/DataProductsWatcher.js +++ b/src/firefly/js/metaConvert/DataProductsWatcher.js @@ -9,13 +9,18 @@ import {getStatusFromFetchError} from '../util/WebUtil.js'; import {isDataProductsTable} from '../voAnalyzer/TableAnalysis.js'; import {Band} from '../visualize/Band.js'; import {TABLE_SELECT, TABLE_HIGHLIGHT, TABLE_REMOVE, TABLE_UPDATE, TBL_RESULTS_ACTIVE} from '../tables/TablesCntlr.js'; -import ImagePlotCntlr, {visRoot, dispatchDeletePlotView, MOUSE_CLICK_REASON} from '../visualize/ImagePlotCntlr.js'; -import {REINIT_APP} from '../core/AppDataCntlr.js'; +import {visRoot} from '../visualize/VisStoreRoots'; +import {dispatchDeletePlotView} from '../visualize/ImagePlotDispatch'; +import { + ADD_VIEWER, ANY_REPLOT, CHANGE_ACTIVE_PLOT_VIEW, CHANGE_VIEWER_LAYOUT, GRID, GRID_FULL, GRID_RELATED, + MOUSE_CLICK_REASON, SINGLE, + UPDATE_VIEW_SIZE, UPDATE_VIEWER_CUSTOM_DATA, UserZoomTypes, VIEWER_MOUNTED, VIEWER_UNMOUNTED +} from '../visualize/VisConst'; +import {REINIT_APP} from '../core/CoreConst'; import {getTblById,getTblInfo,getActiveTableId,isTblDataAvail} from '../tables/TableUtil.js'; import {isDefaultCoverageActive} from '../visualize/PlotViewUtil.js'; -import MultiViewCntlr, { - getViewerItemIds, dispatchChangeViewerLayout, - getMultiViewRoot, getViewer, GRID, GRID_FULL, SINGLE, getLayoutType, getLayoutDetails, GRID_RELATED +import { + getViewerItemIds, dispatchChangeViewerLayout, getMultiViewRoot, getViewer, getLayoutType, getLayoutDetails } from '../visualize/MultiViewCntlr.js'; import { makeDataProductsConverter, getFactoryTemplateOptions @@ -27,7 +32,6 @@ import { dataProductRoot, dispatchUpdateDataProducts, getActivateParams } from './DataProductsCntlr.js'; import {dpdtMessage, dpdtSimpleMsg, DPtypes} from './DataProductsType.js'; -import {UserZoomTypes} from '../visualize/ZoomUtil.js'; import {DEFAULT_DATA_PRODUCTS_COMPONENT_KEY} from 'firefly/metaConvert/DataProductConst'; const MAX_GRID_SIZE= 50; @@ -41,12 +45,8 @@ const getDataProductsWatcherDef = () => ({ allowMultiples: false, actions: [TABLE_SELECT,TABLE_HIGHLIGHT, TABLE_UPDATE, TABLE_REMOVE, TBL_RESULTS_ACTIVE, REINIT_APP, - MultiViewCntlr.ADD_VIEWER, MultiViewCntlr.VIEWER_MOUNTED, - MultiViewCntlr.VIEWER_UNMOUNTED, - MultiViewCntlr.CHANGE_VIEWER_LAYOUT, MultiViewCntlr.UPDATE_VIEWER_CUSTOM_DATA, - ComponentCntlr.COMPONENT_STATE_CHANGE, - ImagePlotCntlr.CHANGE_ACTIVE_PLOT_VIEW, - ImagePlotCntlr.UPDATE_VIEW_SIZE, ImagePlotCntlr.ANY_REPLOT] + ADD_VIEWER, VIEWER_MOUNTED, VIEWER_UNMOUNTED, CHANGE_VIEWER_LAYOUT, UPDATE_VIEWER_CUSTOM_DATA, + ComponentCntlr.COMPONENT_STATE_CHANGE, CHANGE_ACTIVE_PLOT_VIEW, UPDATE_VIEW_SIZE, ANY_REPLOT] }); export function startDataProductsWatcher({dataTypeViewerId= DEFAULT_DATA_PRODUCTS_COMPONENT_KEY, factoryKey, paused=true}) { @@ -133,8 +133,8 @@ function watchDataProductsTable(tbl_id, action, cancelSelf, params) { zoomOnNextViewSizeChange= false; break; - case MultiViewCntlr.CHANGE_VIEWER_LAYOUT: - case MultiViewCntlr.UPDATE_VIEWER_CUSTOM_DATA: + case CHANGE_VIEWER_LAYOUT: + case UPDATE_VIEWER_CUSTOM_DATA: if (!paused && !ignoreCustomDataChange) { abortPromise= updateDataProducts(factoryKey, action, firstTime, tbl_id, activateParams, abortLastPromise); firstTime= false; @@ -143,7 +143,7 @@ function watchDataProductsTable(tbl_id, action, cancelSelf, params) { break; - case MultiViewCntlr.ADD_VIEWER: + case ADD_VIEWER: if (payload.mounted) { abortPromise= updateDataProducts(factoryKey, action, firstTime, tbl_id, activateParams, abortLastPromise); firstTime= false; @@ -152,14 +152,14 @@ function watchDataProductsTable(tbl_id, action, cancelSelf, params) { } break; - case MultiViewCntlr.VIEWER_MOUNTED: + case VIEWER_MOUNTED: paused= false; abortPromise= updateDataProducts(factoryKey, action, firstTime, tbl_id, activateParams, abortLastPromise); firstTime= false; zoomOnNextViewSizeChange= false; break; - case MultiViewCntlr.VIEWER_UNMOUNTED: + case VIEWER_UNMOUNTED: paused= true; zoomOnNextViewSizeChange= false; break; @@ -172,13 +172,13 @@ function watchDataProductsTable(tbl_id, action, cancelSelf, params) { break; - case ImagePlotCntlr.CHANGE_ACTIVE_PLOT_VIEW: + case CHANGE_ACTIVE_PLOT_VIEW: if (!paused && action.payload.reason===MOUSE_CLICK_REASON) { changeTableHighlightToMatchPlotView(action.payload.plotId,tbl_id); } break; - case ImagePlotCntlr.ANY_REPLOT: + case ANY_REPLOT: if (!paused) { const makeActive= !isDefaultCoverageActive(visRoot(),getMultiViewRoot()); if (makeActive) resetImageFullGridActivePlot(tbl_id, action.payload.plotIdAry); @@ -186,7 +186,7 @@ function watchDataProductsTable(tbl_id, action, cancelSelf, params) { zoomOnNextViewSizeChange= false; break; - case ImagePlotCntlr.UPDATE_VIEW_SIZE: + case UPDATE_VIEW_SIZE: if (!paused && zoomOnNextViewSizeChange) { zoomPlotPerViewSize(payload.plotId, UserZoomTypes.FIT); } @@ -217,8 +217,7 @@ const getKey= (threeOp, band) => */ function updateDataProducts(factoryKey, action, firstTime, tbl_id, activateParams, abortLastPromise=undefined) { - const layoutChange= action?.type===MultiViewCntlr.CHANGE_VIEWER_LAYOUT || - action?.type===MultiViewCntlr.UPDATE_VIEWER_CUSTOM_DATA; + const layoutChange= action?.type===CHANGE_VIEWER_LAYOUT || action?.type===UPDATE_VIEWER_CUSTOM_DATA; abortLastPromise && !layoutChange && abortLastPromise(); diff --git a/src/firefly/js/metaConvert/DefaultConverter.js b/src/firefly/js/metaConvert/DefaultConverter.js index 032177da75..3ced3586d6 100644 --- a/src/firefly/js/metaConvert/DefaultConverter.js +++ b/src/firefly/js/metaConvert/DefaultConverter.js @@ -6,7 +6,7 @@ import CoordinateSys from '../visualize/CoordSys.js'; import {makeWorldPt, parseWorldPt} from '../visualize/Point.js'; import RangeValues from '../visualize/RangeValues.js'; import {TitleOptions, WebPlotRequest} from '../visualize/WebPlotRequest.js'; -import {ZoomType} from '../visualize/ZoomType.js'; +import {ZoomType} from '../visualize/VisConst'; const FILE = 'FILE'; diff --git a/src/firefly/js/metaConvert/ImageDataProductsUtil.js b/src/firefly/js/metaConvert/ImageDataProductsUtil.js index a9ada2cb07..ec009b0adf 100644 --- a/src/firefly/js/metaConvert/ImageDataProductsUtil.js +++ b/src/firefly/js/metaConvert/ImageDataProductsUtil.js @@ -8,19 +8,22 @@ import {dispatchTableHighlight} from '../tables/TablesCntlr.js'; import {getActiveTableId, getCellValue, getTblById} from '../tables/TableUtil.js'; import {uniqueID} from '../util/WebUtil'; import {allBandAry} from '../visualize/Band.js'; -import ImagePlotCntlr, { - dispatchChangeActivePlotView, dispatchDeletePlotView, dispatchPlotImage, dispatchZoom, visRoot -} from '../visualize/ImagePlotCntlr.js'; +import {visRoot} from '../visualize/VisStoreRoots'; import { - DEFAULT_FITS_VIEWER_ID, dispatchReplaceViewerItems, getLayoutType, getMultiViewRoot, getViewerItemIds, GRID, IMAGE + dispatchChangeActivePlotView, dispatchDeletePlotView, dispatchPlotImage, dispatchZoom +} from '../visualize/ImagePlotDispatch'; +import { + CHANGE_ACTIVE_PLOT_VIEW, DEFAULT_FITS_VIEWER_ID, GRID, IMAGE, PLOT_IMAGE, PLOT_IMAGE_FAIL, ZoomType +} from '../visualize/VisConst'; +import { + dispatchReplaceViewerItems, getLayoutType, getMultiViewRoot, getViewerItemIds, } from '../visualize/MultiViewCntlr.js'; -import {PlotAttribute as PlotAttribues, PlotAttribute} from '../visualize/PlotAttribute.js'; +import {PlotAttribute} from '../visualize/PlotAttribute.js'; import {getPlotGroupById} from '../visualize/PlotGroup.js'; import { - getActivePlotView, getPlotViewAry, getPlotViewById, isDefaultCoverageActive, isImageExpanded, primePlot + currentP, getPlotViewAry, getPlotViewById, isDefaultCoverageActive, isImageExpanded, primePlot } from '../visualize/PlotViewUtil.js'; import { getDefaultImageColorTable, isImageDataRequestedEqual, WebPlotRequest } from '../visualize/WebPlotRequest.js'; -import {ZoomType} from '../visualize/ZoomType.js'; export function createRelatedDataGridActivate(reqRet, imageViewerId, tbl_id, highlightPlotId) { @@ -114,12 +117,12 @@ export function createSingleImageExtraction(request, sourceObsCoreData, dlData) if (!request) return undefined; const wpRequest= isArray(request) ? request.map( (r) => copyRequest(r)) : copyRequest(request); const plotIds= isArray(request) ? request.map( (r) => r.getPlotId()) : copyRequest(request); - const attributes= {[PlotAttribues.USER_PINNED_IMAGE]:true}; + const attributes= {[PlotAttribute.USER_PINNED_IMAGE]:true}; if (sourceObsCoreData) attributes.sourceObsCoreData= sourceObsCoreData; if (dlData) attributes.dlData= dlData; return () => { if (isArray(wpRequest)) { - const activePlotId= getActivePlotView(visRoot())?.plotId; + const activePlotId=currentP().plotId; const idx= plotIds.findIndex( (id) => id===activePlotId); if (idx<0) return; dispatchPlotImage({ viewerId:DEFAULT_FITS_VIEWER_ID, @@ -136,7 +139,7 @@ export function createSingleImageExtraction(request, sourceObsCoreData, dlData) function watchForPvChange(action, cancelSelf, params) { const {payload,type}= action; - if (type===ImagePlotCntlr.CHANGE_ACTIVE_PLOT_VIEW) { + if (type===CHANGE_ACTIVE_PLOT_VIEW) { params?.onActivePvChanged(payload.plotId); return; } @@ -149,7 +152,7 @@ export function setupWatchForPvChange(watcherId, onActivePvChanged) { callback: watchForPvChange, id: watcherId, params: {onActivePvChanged}, - actions: [ImagePlotCntlr.CHANGE_ACTIVE_PLOT_VIEW] + actions: [CHANGE_ACTIVE_PLOT_VIEW] } ); } @@ -159,12 +162,12 @@ function watchForCompletedPlot(action, cancelSelf, params) { const {afterComplete, plotId}= params; const {payload,type}= action; - if (type===ImagePlotCntlr.PLOT_IMAGE_FAIL) { + if (type===PLOT_IMAGE_FAIL) { if (payload.plotId!==plotId) return; cancelSelf(); return; } - if (type===ImagePlotCntlr.PLOT_IMAGE) { + if (type===PLOT_IMAGE) { if (!payload.pvNewPlotInfoAry.some( (n) => n.plotId===plotId)) { return; } @@ -187,7 +190,7 @@ export function zoomPlotPerViewSize(plotId, zoomType) { dispatchAddActionWatcher( { callback: watchForCompletedPlot, params: {plotId, afterComplete}, - actions: [ImagePlotCntlr.PLOT_IMAGE, ImagePlotCntlr.PLOT_IMAGE_FAIL] + actions: [PLOT_IMAGE, PLOT_IMAGE_FAIL] } ); } else { @@ -204,7 +207,7 @@ function onImagePlotComplete(plotId,onComplete) { dispatchAddActionWatcher( { callback: watchForCompletedPlot, params: {plotId, afterComplete}, - actions: [ImagePlotCntlr.PLOT_IMAGE, ImagePlotCntlr.PLOT_IMAGE_FAIL] + actions: [PLOT_IMAGE, PLOT_IMAGE_FAIL] } ); } else { @@ -308,7 +311,7 @@ function replotImageDataProducts(activePlotId, makeActive, imageViewerId, tbl_id // clean up unused Ids const cleanUpIds= difference(plotIdsInViewer,plottingIds); - cleanUpIds.forEach( (plotId) => dispatchDeletePlotView({plotId, holdWcsMatch:true})); + cleanUpIds.forEach( (plotId) => dispatchDeletePlotView({plotId})); // prepare standard plot diff --git a/src/firefly/js/metaConvert/TableDataProductUtils.js b/src/firefly/js/metaConvert/TableDataProductUtils.js index 2416a6b9de..2018a54579 100644 --- a/src/firefly/js/metaConvert/TableDataProductUtils.js +++ b/src/firefly/js/metaConvert/TableDataProductUtils.js @@ -22,6 +22,7 @@ import { import {getActiveTableId, getMetaEntry, getTblById, onTableLoaded} from '../tables/TableUtil'; import {getCellValue, getTblInfo} from '../tables/TableUtil.js'; import MultiViewCntlr, {dispatchUpdateCustom, getMultiViewRoot, getViewer} from '../visualize/MultiViewCntlr.js'; +import {UPDATE_VIEWER_CUSTOM_DATA} from '../visualize/VisConst'; import { getObsCoreAccessURL, getObsCoreSRegion, getSearchTarget, isFormatDataLink, makeWorldPtUsingCenterColumns } from '../voAnalyzer/TableAnalysis'; @@ -485,7 +486,7 @@ export function makeMultiTableActivate(activateObj,activateParams) { const watcher= (action) => { let idx; switch (action.type) { - case MultiViewCntlr.UPDATE_VIEWER_CUSTOM_DATA: + case UPDATE_VIEWER_CUSTOM_DATA: const chartId= action.payload.customData.activeItemId; if (!chartList.includes(chartId)) return; idx= chartList.indexOf(chartId); @@ -506,7 +507,7 @@ export function makeMultiTableActivate(activateObj,activateParams) { } }; - dispatchAddActionWatcher({id, actions:[MultiViewCntlr.UPDATE_VIEWER_CUSTOM_DATA,TBL_RESULTS_ACTIVE], callback:watcher}); + dispatchAddActionWatcher({id, actions:[UPDATE_VIEWER_CUSTOM_DATA,TBL_RESULTS_ACTIVE], callback:watcher}); return () => { const tbl_id= getActiveTableId(activateParams.tableGroupViewerId); if (tbl_id) { diff --git a/src/firefly/js/metaConvert/UploadAndAnalysis.js b/src/firefly/js/metaConvert/UploadAndAnalysis.js index 1f93554536..44dda65efc 100644 --- a/src/firefly/js/metaConvert/UploadAndAnalysis.js +++ b/src/firefly/js/metaConvert/UploadAndAnalysis.js @@ -8,7 +8,7 @@ import {upload} from '../rpc/CoreServices.js'; import {getMetaEntry, getTblById, getTblRowAsObj} from '../tables/TableUtil'; import {hashCode} from '../util/WebUtil'; import {isDefined} from '../util/WebUtil.js'; -import ImagePlotCntlr from '../visualize/ImagePlotCntlr'; +import {PLOT_PROGRESS_UPDATE} from '../visualize/VisConst'; import {getObsTitle} from '../voAnalyzer/TableAnalysis'; import {getObsCoreData} from '../voAnalyzer/VoDataLinkServDef'; import {makePdfEntry, makePngEntry, makeTarEntry, makeTextEntry} from './AnalysisUtils'; @@ -120,7 +120,7 @@ export async function doUploadAndAnalysis({ table, row, request, activateParams= const startUpdateWatcher= (url,dpId) => - url && dispatchAddActionWatcher({ id: url, actions:[ImagePlotCntlr.PLOT_PROGRESS_UPDATE], + url && dispatchAddActionWatcher({ id: url, actions:[PLOT_PROGRESS_UPDATE], callback:watchForUploadUpdate, params:{url,dpId}}); const endUpdateWatcher= (url) => url && dispatchCancelActionWatcher(url); diff --git a/src/firefly/js/metaConvert/missions/ShaRequestList.js b/src/firefly/js/metaConvert/missions/ShaRequestList.js index c9406025bd..a481739047 100644 --- a/src/firefly/js/metaConvert/missions/ShaRequestList.js +++ b/src/firefly/js/metaConvert/missions/ShaRequestList.js @@ -5,9 +5,9 @@ import {getCellValue} from '../../tables/TableUtil.js'; import {PlotAttribute} from '../../visualize/PlotAttribute'; import {makeWorldPt} from '../../visualize/Point.js'; import {CoordinateSys} from '../../visualize/CoordSys.js'; +import {GRID_FULL, SINGLE} from '../../visualize/VisConst'; import {WebPlotRequest} from '../../visualize/WebPlotRequest.js'; import {addCommonReqParams} from '../../templates/lightcurve/LcConverterFactory.js'; -import {GRID_FULL, SINGLE} from '../../visualize/MultiViewCntlr'; import {getRootURL} from '../../util/WebUtil.js'; /** diff --git a/src/firefly/js/metaConvert/missions/WiseRequestList.js b/src/firefly/js/metaConvert/missions/WiseRequestList.js index 73dc77412c..4f250cffde 100644 --- a/src/firefly/js/metaConvert/missions/WiseRequestList.js +++ b/src/firefly/js/metaConvert/missions/WiseRequestList.js @@ -4,6 +4,7 @@ import {get, isNil} from 'lodash'; +import {GRID_FULL, GRID_RELATED} from '../../visualize/VisConst'; import {makeServerRequestBuilder} from '../ImageDataProductsUtil.js'; import {RangeValues,STRETCH_LINEAR,SIGMA} from '../../visualize/RangeValues.js'; import {getCellValue, getMetaEntry} from '../../tables/TableUtil.js'; @@ -11,7 +12,6 @@ import {makeWorldPt} from '../../visualize/Point.js'; import {convertAngle} from '../../visualize/VisUtil.js'; import {PlotAttribute} from '../../visualize/PlotAttribute.js'; import {CoordinateSys} from '../../visualize/CoordSys.js'; -import {GRID_FULL, GRID_RELATED} from '../../visualize/MultiViewCntlr.js'; import {Band} from '../../visualize/Band.js'; const colToUse= ['scan_id', 'frame_num', 'coadd_id', 'in_ra', 'in_dec', 'image_set']; diff --git a/src/firefly/js/metaConvert/missions/ZtfRequestList.js b/src/firefly/js/metaConvert/missions/ZtfRequestList.js index 20b22ccd64..3ec6bee3d6 100644 --- a/src/firefly/js/metaConvert/missions/ZtfRequestList.js +++ b/src/firefly/js/metaConvert/missions/ZtfRequestList.js @@ -4,7 +4,7 @@ import {RangeValues,STRETCH_LINEAR,SIGMA} from '../../visualize/RangeValues.js'; import {getCellValue} from '../../tables/TableUtil.js'; import {makeWebPlotRequestViaZtfIbe} from '../../templates/lightcurve/ztf/IbeZTFPlotRequests.js'; -import {GRID_FULL, SINGLE} from '../../visualize/MultiViewCntlr.js'; +import {GRID_FULL, SINGLE} from '../../visualize/VisConst'; const rangeValues= RangeValues.makeRV({which:SIGMA, lowerValue:-2, upperValue:10, algorithm:STRETCH_LINEAR}); diff --git a/src/firefly/js/metaConvert/vo/DatalinkProducts.js b/src/firefly/js/metaConvert/vo/DatalinkProducts.js index af3ee42e9a..1edee3c258 100644 --- a/src/firefly/js/metaConvert/vo/DatalinkProducts.js +++ b/src/firefly/js/metaConvert/vo/DatalinkProducts.js @@ -2,8 +2,7 @@ import {cloneRequest, MAX_ROW} from '../../tables/TableRequestUtil'; import {doFetchTable, getCellValue, getColumnByRef, getMetaEntry} from '../../tables/TableUtil.js'; import {getPreferCutout} from '../../ui/tap/Cutout'; import {logger} from '../../util/Logger'; -import {visRoot} from '../../visualize/ImagePlotCntlr'; -import {primePlot} from '../../visualize/PlotViewUtil'; +import {currentP} from '../../visualize/PlotViewUtil'; import {getObsCoreAccessURL} from '../../voAnalyzer/TableAnalysis'; import {getDataLinkData} from '../../voAnalyzer/VoDataLinkServDef.js'; import {Band} from '../../visualize/Band.js'; @@ -213,7 +212,7 @@ function getOnActivePvChanged(dlTableUrl, dataLinkGrid, activateParams, options) if (!menuKeyAry?.length) return; return (plotId) => { const activeMenuLookupKey= dlTableUrl; - const menuKey= findMenuKeyWithName(menuKeyAry,primePlot(visRoot(),plotId)?.title); + const menuKey= findMenuKeyWithName(menuKeyAry,currentP(plotId).plot?.title); if (!menuKey) return; dispatchUpdateActiveKey({dpId: activateParams.dpId, activeMenuKeyChanges:{[activeMenuLookupKey]:menuKey}}); }; diff --git a/src/firefly/js/metaConvert/vo/ObsCoreConverter.js b/src/firefly/js/metaConvert/vo/ObsCoreConverter.js index f2279ba089..b795e5a8df 100644 --- a/src/firefly/js/metaConvert/vo/ObsCoreConverter.js +++ b/src/firefly/js/metaConvert/vo/ObsCoreConverter.js @@ -41,7 +41,7 @@ export function makeObsCoreConverter(table,converterTemplate,options={}) { return { ...converterTemplate, initialLayout, - describeThreeColor: threeColor ? describeObsThreeColor : undefined, + describeThreeColor: threeColorConfirmed ? describeObsThreeColor : undefined, threeColor:threeColorConfirmed, canGrid:canGridConfirmed, hasRelatedBands:hasRelatedBandsConfirmed, diff --git a/src/firefly/js/tables/HpxIndexCntlr.js b/src/firefly/js/tables/HpxIndexCntlr.js index 3f88bb989f..bb6724401e 100644 --- a/src/firefly/js/tables/HpxIndexCntlr.js +++ b/src/firefly/js/tables/HpxIndexCntlr.js @@ -7,7 +7,7 @@ import {ang2pixNest, radecToPolar} from '../externalSource/aladinProj/HealpixInd import {logger} from '../util/Logger'; import {blockWhileAsyncIdWaiting, synchronizeAsyncFunctionById} from '../util/SynchronizeAsync'; import {createBackgroundRunner, isDefined} from '../util/WebUtil'; -import {DEFAULT_COVERAGE_PLOT_ID} from '../visualize/PlotViewUtil'; +import {DEFAULT_COVERAGE_PLOT_ID} from '../visualize/VisConst'; import {makeWorldPt} from '../visualize/Point'; import {convertCelestial} from '../visualize/VisUtil'; import {findTableCenterColumns, makeWorldPtUsingCenterColumns} from '../voAnalyzer/TableAnalysis'; diff --git a/src/firefly/js/tables/TablesCntlr.js b/src/firefly/js/tables/TablesCntlr.js index 2f030813be..f4f554dce7 100644 --- a/src/firefly/js/tables/TablesCntlr.js +++ b/src/firefly/js/tables/TablesCntlr.js @@ -15,7 +15,8 @@ import {Logger} from '../util/Logger.js'; import {FilterInfo} from './FilterInfo.js'; import {selectedValues, asyncFetchTable} from '../rpc/SearchServicesJson.js'; import {trackBackgroundJob, isSuccess, isDone, getErrMsg, handleJobResult} from '../core/background/BackgroundUtil.js'; -import {REINIT_APP, getAppOptions} from '../core/AppDataCntlr.js'; +import {REINIT_APP} from '../core/CoreConst'; +import {getAppOptions} from '../core/AppDataCntlr.js'; import {dispatchComponentStateChange} from '../core/ComponentCntlr.js'; import {dispatchJobAdd} from '../core/background/BackgroundCntlr.js'; import {ensureEnumVals, fixPageSize, getTblById} from './TableUtil.js'; diff --git a/src/firefly/js/templates/common/MainPanel.jsx b/src/firefly/js/templates/common/MainPanel.jsx index 7c07d7bb43..ba75c2012b 100644 --- a/src/firefly/js/templates/common/MainPanel.jsx +++ b/src/firefly/js/templates/common/MainPanel.jsx @@ -6,11 +6,11 @@ import {useStoreConnector} from 'firefly/ui/SimpleComponent.jsx'; import {TablesContainer} from 'firefly/tables/ui/TablesContainer.jsx'; import {getExpandedChartProps} from 'firefly/charts/ChartsCntlr.js'; import {ChartsContainer} from 'firefly/charts/ui/ChartsContainer.jsx'; -import {DEFAULT_PLOT2D_VIEWER_ID} from 'firefly/visualize/MultiViewCntlr.js'; import {ImageExpandedMode} from 'firefly/visualize/iv/ImageExpandedMode.jsx'; import {VersionInfo} from 'firefly/ui/VersionInfo.jsx'; import FOOTER_BG from 'images/ipac_bar.jpg'; +import {DEFAULT_PLOT2D_VIEWER_ID} from '../../visualize/VisConst'; /** * Main panel of the FireflyLayout. It handles the 3 possible views: drop-down, standard, expanded. diff --git a/src/firefly/js/templates/fireflyslate/FireflySlate.jsx b/src/firefly/js/templates/fireflyslate/FireflySlate.jsx index 8e77c43989..8dddd94ed7 100644 --- a/src/firefly/js/templates/fireflyslate/FireflySlate.jsx +++ b/src/firefly/js/templates/fireflyslate/FireflySlate.jsx @@ -15,8 +15,9 @@ import {TablesContainer} from '../../tables/ui/TablesContainer.jsx'; import {ChartsContainer} from '../../charts/ui/ChartsContainer.jsx'; import {getExpandedChartProps} from '../../charts/ChartsCntlr.js'; import {AppPropertiesCtx} from '../../ui/AppPropertiesCtx.jsx'; -import {visRoot} from '../../visualize/ImagePlotCntlr.js'; -import {getMultiViewRoot, findViewerWithItemId, PLOT2D} from '../../visualize/MultiViewCntlr.js'; +import {PLOT2D} from '../../visualize/VisConst'; +import {visRoot} from '../../visualize/VisStoreRoots'; +import {getMultiViewRoot, findViewerWithItemId} from '../../visualize/MultiViewCntlr.js'; import {ImageExpandedMode} from '../../visualize/iv/ImageExpandedMode.jsx'; import {startTTFeatureWatchers} from '../common/ttFeatureWatchers.js'; import {RenderTreeIdCtx} from '../../ui/RenderTreeIdCtx.jsx'; @@ -124,6 +125,9 @@ const closeExpanded= () => dispatchSetLayoutMode(LO_MODE.expanded, LO_VIEW.none) * @param props * @param props.expanded * @param props.gridView + * @param props.gridColumns + * @param props.initLoadingMessage + * @param props.initLoadCompleted * @return {*} */ function mainView({expanded,gridView, gridColumns, initLoadingMessage, initLoadCompleted}) { diff --git a/src/firefly/js/templates/fireflyslate/FireflySlateManager.js b/src/firefly/js/templates/fireflyslate/FireflySlateManager.js index 2a2ab372fb..65cccc5e32 100644 --- a/src/firefly/js/templates/fireflyslate/FireflySlateManager.js +++ b/src/firefly/js/templates/fireflyslate/FireflySlateManager.js @@ -2,7 +2,7 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import {filter, isEmpty, isArray, uniq, once} from 'lodash'; +import {filter, isEmpty, isArray, uniq} from 'lodash'; import {startCoverageWatcher} from '../../visualize/saga/CoverageWatcher.js'; @@ -16,16 +16,15 @@ import {dispatchLoadTblStats} from '../../charts/TableStatsCntlr'; import {CHART_ADD, CHART_REMOVE} from '../../charts/ChartsCntlr.js'; import {clone} from '../../util/WebUtil.js'; -import ImagePlotCntlr from '../../visualize/ImagePlotCntlr.js'; -import {REPLACE_VIEWER_ITEMS, IMAGE, getViewerItemIds, getMultiViewRoot, getViewer, findViewerWithItemId} from '../../visualize/MultiViewCntlr.js'; +import {DELETE_PLOT_VIEW, IMAGE, PLOT_IMAGE, PLOT_IMAGE_START, REPLACE_VIEWER_ITEMS} from '../../visualize/VisConst'; +import {getViewerItemIds, getMultiViewRoot, getViewer, findViewerWithItemId} from '../../visualize/MultiViewCntlr.js'; import {dispatchAddActionWatcher, dispatchCancelActionWatcher} from '../../core/MasterSaga.js'; export function startLayoutManager(id, params) { const actions = [ - ImagePlotCntlr.PLOT_IMAGE_START, ImagePlotCntlr.PLOT_IMAGE, - ImagePlotCntlr.DELETE_PLOT_VIEW, REPLACE_VIEWER_ITEMS, + PLOT_IMAGE_START, PLOT_IMAGE, DELETE_PLOT_VIEW, REPLACE_VIEWER_ITEMS, TABLE_REMOVE, TABLE_LOADED, TBL_RESULTS_ADDED, TBL_RESULTS_ACTIVE, CHART_ADD, CHART_REMOVE, SHOW_DROPDOWN, SET_LAYOUT_MODE, ENABLE_SPECIAL_VIEWER @@ -55,13 +54,13 @@ function layoutManager(action, cancelSelf, params) { let newLayoutInfo = layoutInfo; switch (action.type) { - case ImagePlotCntlr.PLOT_IMAGE_START: - case ImagePlotCntlr.PLOT_IMAGE : + case PLOT_IMAGE_START: + case PLOT_IMAGE : case REPLACE_VIEWER_ITEMS: newLayoutInfo = handleNewImage(newLayoutInfo, action, renderTreeId); break; - case ImagePlotCntlr.DELETE_PLOT_VIEW: + case DELETE_PLOT_VIEW: newLayoutInfo = handlePlotDelete(newLayoutInfo, action, renderTreeId); break; case TBL_RESULTS_ADDED: diff --git a/src/firefly/js/templates/fireflyslate/GridLayoutPanel.jsx b/src/firefly/js/templates/fireflyslate/GridLayoutPanel.jsx index 81b6263699..a745af0826 100644 --- a/src/firefly/js/templates/fireflyslate/GridLayoutPanel.jsx +++ b/src/firefly/js/templates/fireflyslate/GridLayoutPanel.jsx @@ -14,7 +14,7 @@ import {MultiViewStandardToolbar} from '../../visualize/ui/MultiViewStandardTool import {MultiChartViewer} from '../../charts/ui/MultiChartViewer.jsx'; import {TablesContainer} from '../../tables/ui/TablesContainer.jsx'; import {LO_VIEW, getGridDim, dispatchUpdateGridView} from '../../core/LayoutCntlr.js'; -import {NewPlotMode} from '../../visualize/MultiViewCntlr.js'; +import {NewPlotMode} from '../../visualize/VisConst'; import {RenderTreeIdCtx} from '../../ui/RenderTreeIdCtx.jsx'; import {getActiveTableId} from '../../tables/TableUtil.js'; diff --git a/src/firefly/js/templates/fireflyviewer/FireflyViewerManager.js b/src/firefly/js/templates/fireflyviewer/FireflyViewerManager.js index fca07229d5..d612e7a4e8 100644 --- a/src/firefly/js/templates/fireflyviewer/FireflyViewerManager.js +++ b/src/firefly/js/templates/fireflyviewer/FireflyViewerManager.js @@ -11,30 +11,27 @@ import {getTblById, smartMerge} from '../../tables/TableUtil.js'; import {TBL_RESULTS_ADDED, TABLE_LOADED, TABLE_REMOVE, TBL_RESULTS_ACTIVE, TBL_RESULTS_REMOVE} from '../../tables/TablesCntlr.js'; import {CHART_ADD, CHART_REMOVE} from '../../charts/ChartsCntlr.js'; -import ImagePlotCntlr from '../../visualize/ImagePlotCntlr.js'; -import {REPLACE_VIEWER_ITEMS} from '../../visualize/MultiViewCntlr.js'; +import {DELETE_PLOT_VIEW, PLOT_HIPS, PLOT_IMAGE, PLOT_IMAGE_START, REPLACE_VIEWER_ITEMS} from '../../visualize/VisConst'; import {MetaConst} from 'firefly/data/MetaConst'; /** * this manager manages what main components get display on the screen. * These main components are image plots, charts, tables, dropdown panel, etc. * This manager implements the default firefly viewer's requirements. - * Because it may differs between applications, it is okay to have a custom layout manager if needed. + * Because it may differ between applications, it is okay to have a custom layout manager if needed. * @param {object} p - * @param {string} [p.title] title to display * @param {string} [p.views] defaults to tri-view if not given. + * @param {string} [p.apiHandlesExpanded] */ -export function* layoutManager({title, views='tables | images | xyplots', apiHandlesExpanded}) { +export function* layoutManager({views='tables | images | xyplots', apiHandlesExpanded}) { views = LO_VIEW.get(views) || LO_VIEW.none; yield fork(dropDownManager); // start the dropdown manager while (true) { const action = yield take([ - ImagePlotCntlr.PLOT_IMAGE_START, ImagePlotCntlr.PLOT_IMAGE, ImagePlotCntlr.PLOT_HIPS, - ImagePlotCntlr.DELETE_PLOT_VIEW, REPLACE_VIEWER_ITEMS, + PLOT_IMAGE_START, PLOT_IMAGE, PLOT_HIPS, DELETE_PLOT_VIEW, REPLACE_VIEWER_ITEMS, TABLE_REMOVE, TABLE_LOADED, TBL_RESULTS_ADDED, TBL_RESULTS_ACTIVE, TBL_RESULTS_REMOVE, - CHART_ADD, CHART_REMOVE, - SHOW_DROPDOWN, SET_LAYOUT_MODE + CHART_ADD, CHART_REMOVE, SHOW_DROPDOWN, SET_LAYOUT_MODE ]); /** @@ -90,9 +87,9 @@ function onAnyAction(layoutInfo, action, views, apiHandlesExpanded) { case TABLE_REMOVE: case TBL_RESULTS_REMOVE: case REPLACE_VIEWER_ITEMS: - case ImagePlotCntlr.PLOT_IMAGE_START : - case ImagePlotCntlr.DELETE_PLOT_VIEW: - case ImagePlotCntlr.PLOT_HIPS: + case PLOT_IMAGE_START : + case DELETE_PLOT_VIEW: + case PLOT_HIPS: case CHART_ADD: case CHART_REMOVE: { diff --git a/src/firefly/js/templates/fireflyviewer/TriViewPanel.jsx b/src/firefly/js/templates/fireflyviewer/TriViewPanel.jsx index 63d6a4da07..f2f747d6de 100644 --- a/src/firefly/js/templates/fireflyviewer/TriViewPanel.jsx +++ b/src/firefly/js/templates/fireflyviewer/TriViewPanel.jsx @@ -18,10 +18,10 @@ import {AppInitLoadingMessage} from '../../ui/AppInitLoadingMessage.jsx'; import {AppPropertiesCtx} from '../../ui/AppPropertiesCtx.jsx'; import {Tab, TabPanel} from '../../ui/panel/TabPanel.jsx'; import {useStoreConnector} from '../../ui/SimpleComponent.jsx'; -import {DEFAULT_PLOT2D_VIEWER_ID, PINNED_CHART_VIEWER_ID} from '../../visualize/MultiViewCntlr.js'; import { makeCoverageTab, makeFitsPinnedTab, makeMultiProductViewerTab, TriViewImageSection } from '../../visualize/ui/TriViewImageSection.jsx'; +import {DEFAULT_PLOT2D_VIEWER_ID, PINNED_CHART_VIEWER_ID} from '../../visualize/VisConst'; import {ResultsPanel} from './ResultsPanel.jsx'; const stateKeys= ['title', 'mode', 'showTables', 'showImages', 'showXyPlots', 'images', 'coverageSide', 'initLoadCompleted']; diff --git a/src/firefly/js/templates/hydra/HydraManager.js b/src/firefly/js/templates/hydra/HydraManager.js index 72080ece27..53591b339b 100644 --- a/src/firefly/js/templates/hydra/HydraManager.js +++ b/src/firefly/js/templates/hydra/HydraManager.js @@ -4,19 +4,17 @@ import {take, fork} from 'redux-saga/effects'; import { - SHOW_DROPDOWN, SET_LAYOUT_MODE, getLayouInfo, - dispatchSetLayoutInfo, dropDownManager, getResultCounts + SHOW_DROPDOWN, SET_LAYOUT_MODE, getLayouInfo, dispatchSetLayoutInfo, dropDownManager, getResultCounts } from '../../core/LayoutCntlr.js'; import {removeChartsInGroup} from '../../charts/ChartsCntlr.js'; -import {TABLE_SEARCH, TBL_RESULTS_ADDED, TABLE_REMOVE -} from '../../tables/TablesCntlr.js'; -import {visRoot, dispatchDeletePlotView} from '../../visualize/ImagePlotCntlr.js'; +import {TABLE_SEARCH, TBL_RESULTS_ADDED, TABLE_REMOVE} from '../../tables/TablesCntlr.js'; +import {dispatchDestroyDrawLayer} from '../../visualize/DrawLayerDispatch'; +import {getDlAry, visRoot} from '../../visualize/VisStoreRoots'; +import {dispatchDeletePlotView} from '../../visualize/ImagePlotDispatch'; import {removeTablesFromGroup, getAllTableGroupIds, smartMerge} from '../../tables/TableUtil.js'; import {getSearchByName, getSearchInfo, getSelectedMenuItem} from '../../core/AppDataCntlr.js'; -import ImagePlotCntlr from '../../visualize/ImagePlotCntlr.js'; +import {DELETE_PLOT_VIEW, PLOT_IMAGE, PLOT_IMAGE_START, REPLACE_VIEWER_ITEMS} from '../../visualize/VisConst'; import {CHART_ADD} from '../../charts/ChartsCntlr.js'; -import {REPLACE_VIEWER_ITEMS} from '../../visualize/MultiViewCntlr.js'; -import {deleteAllDrawLayers} from '../../visualize/DrawLayerCntlr'; /** * Configurable part of this template @@ -41,7 +39,7 @@ export function* hydraManager() { const action = yield take([ SHOW_DROPDOWN, SET_LAYOUT_MODE, CHART_ADD, TABLE_SEARCH, TBL_RESULTS_ADDED, TABLE_REMOVE, - ImagePlotCntlr.PLOT_IMAGE, ImagePlotCntlr.PLOT_IMAGE_START, ImagePlotCntlr.DELETE_PLOT_VIEW, REPLACE_VIEWER_ITEMS + PLOT_IMAGE, PLOT_IMAGE_START, DELETE_PLOT_VIEW, REPLACE_VIEWER_ITEMS ]); /** @@ -124,6 +122,6 @@ export function cleanup() { // remove all plots visRoot().plotViewAry.forEach( (pv) => dispatchDeletePlotView({plotId:pv.plotId})); // remove all drawing layers - deleteAllDrawLayers(); + getDlAry().forEach(({drawLayerId}) => drawLayerId && dispatchDestroyDrawLayer(drawLayerId)); } diff --git a/src/firefly/js/templates/hydra/HydraViewer.jsx b/src/firefly/js/templates/hydra/HydraViewer.jsx index 553ced85de..35d3e11229 100644 --- a/src/firefly/js/templates/hydra/HydraViewer.jsx +++ b/src/firefly/js/templates/hydra/HydraViewer.jsx @@ -15,6 +15,7 @@ import { getSearchInfo, } from '../../core/AppDataCntlr.js'; import {getLayouInfo, LO_VIEW} from '../../core/LayoutCntlr.js'; +import {DEFAULT_PLOT2D_VIEWER_ID} from '../../visualize/VisConst'; import {hydraManager} from './HydraManager'; import {dispatchAddSaga} from '../../core/MasterSaga.js'; @@ -24,7 +25,6 @@ import {ChartsContainer} from '../../charts/ui/ChartsContainer.jsx'; import {startTTFeatureWatchers} from '../common/ttFeatureWatchers.js'; import {dispatchSetLayoutMode, LO_MODE} from '../../core/LayoutCntlr'; import {getExpandedChartProps} from '../../charts/ChartsCntlr.js'; -import {DEFAULT_PLOT2D_VIEWER_ID} from '../../visualize/MultiViewCntlr.js'; import App from 'firefly/ui/App.jsx'; import {Slot, useStoreConnector} from 'firefly/ui/SimpleComponent.jsx'; import {makeMenuItems, SearchPanel} from 'firefly/ui/SearchPanel.jsx'; diff --git a/src/firefly/js/templates/lightcurve/LcImageToolbarView.jsx b/src/firefly/js/templates/lightcurve/LcImageToolbarView.jsx index 50fae78070..f92e2dc7a1 100644 --- a/src/firefly/js/templates/lightcurve/LcImageToolbarView.jsx +++ b/src/firefly/js/templates/lightcurve/LcImageToolbarView.jsx @@ -6,10 +6,12 @@ import {Stack, Switch, Typography} from '@mui/joy'; import React from 'react'; import PropTypes from 'prop-types'; -import {WcsMatchType, visRoot, dispatchWcsMatch} from '../../visualize/ImagePlotCntlr.js'; +import {visRoot} from '../../visualize/VisStoreRoots'; +import {GRID, SINGLE, WcsMatchType} from '../../visualize/VisConst'; +import {dispatchWcsMatch} from '../../visualize/ImagePlotDispatch'; import {RadioGroupInputFieldView} from '../../ui/RadioGroupInputFieldView.jsx'; import { - dispatchChangeViewerLayout, getMultiViewRoot, GRID, SINGLE, getLayoutDetails + dispatchChangeViewerLayout, getMultiViewRoot, getLayoutDetails } from '../../visualize/MultiViewCntlr.js'; import {LC, getConverterData} from './LcManager.js'; import {CloseButton} from '../../ui/CloseButton.jsx'; @@ -65,7 +67,7 @@ function getSortInfo(tableId) { if (sInfo.direction === UNSORTED) return ''; const orderInfo = {[SORT_ASC]: 'ascending', [SORT_DESC]:'descending'}; return `Sorted by column: ${sInfo.sortColumns.join(',')} `+ ` ${orderInfo[sInfo.direction]}`; -}; +} function changeSize(viewerId, value) { const valNum = Number(value); diff --git a/src/firefly/js/templates/lightcurve/LcImageViewerContainer.jsx b/src/firefly/js/templates/lightcurve/LcImageViewerContainer.jsx index fb9e2523e0..73596cd952 100644 --- a/src/firefly/js/templates/lightcurve/LcImageViewerContainer.jsx +++ b/src/firefly/js/templates/lightcurve/LcImageViewerContainer.jsx @@ -5,9 +5,9 @@ import React from 'react'; import PropTypes from 'prop-types'; import {MultiImageViewer} from '../../visualize/ui/MultiImageViewer.jsx'; -import {DEFAULT_FITS_VIEWER_ID, NewPlotMode} from '../../visualize/MultiViewCntlr.js'; +import {DEFAULT_FITS_VIEWER_ID, ExpandType, NewPlotMode} from '../../visualize/VisConst'; import {LO_MODE, LO_VIEW, dispatchSetLayoutMode} from '../../core/LayoutCntlr.js'; -import {dispatchChangeExpandedMode, ExpandType} from '../../visualize/ImagePlotCntlr.js'; +import {dispatchChangeExpandedMode} from '../../visualize/ImagePlotDispatch'; import {LcImageToolbarView} from './LcImageToolbarView.jsx'; /** diff --git a/src/firefly/js/templates/lightcurve/LcManager.js b/src/firefly/js/templates/lightcurve/LcManager.js index 6fc365a3be..44cb293bd3 100644 --- a/src/firefly/js/templates/lightcurve/LcManager.js +++ b/src/firefly/js/templates/lightcurve/LcManager.js @@ -9,14 +9,15 @@ import {TBL_RESULTS_ADDED, TABLE_LOADED, TBL_RESULTS_ACTIVE, TABLE_HIGHLIGHT, TA dispatchTableRemove, dispatchTableHighlight, dispatchTableFetch, dispatchTableSort} from '../../tables/TablesCntlr.js'; import {getCellValue, getTblById, getTblIdsByGroup, getActiveTableId, smartMerge, getColumnIdx, removeTablesFromGroup} from '../../tables/TableUtil.js'; import {updateSet, updateMerge} from '../../util/WebUtil.js'; -import ImagePlotCntlr, {dispatchPlotImage, visRoot, dispatchDeletePlotView, - dispatchChangeActivePlotView, - WcsMatchType, dispatchWcsMatch} from '../../visualize/ImagePlotCntlr.js'; +import { + dispatchChangeActivePlotView, dispatchDeletePlotView, dispatchPlotImage, dispatchWcsMatch +} from '../../visualize/ImagePlotDispatch'; +import {visRoot} from '../../visualize/VisStoreRoots'; import {getPlotViewById} from '../../visualize/PlotViewUtil.js'; import { getMultiViewRoot, dispatchReplaceViewerItems, getViewer, getLayoutDetails } from '../../visualize/MultiViewCntlr.js'; -import {CHANGE_VIEWER_LAYOUT} from '../../visualize/MultiViewCntlr.js'; +import {CHANGE_ACTIVE_PLOT_VIEW, CHANGE_VIEWER_LAYOUT, WcsMatchType} from '../../visualize/VisConst'; import FieldGroupUtils from '../../fieldGroup/FieldGroupUtils'; import {VALUE_CHANGE, dispatchValueChange} from '../../fieldGroup/FieldGroupCntlr.js'; import {MetaConst} from '../../data/MetaConst.js'; @@ -212,7 +213,7 @@ export function* lcManager(params={}) { while (true) { const action = yield take([ TBL_RESULTS_ADDED, TABLE_LOADED, TBL_RESULTS_ACTIVE, TABLE_HIGHLIGHT, TABLE_SEARCH, SHOW_DROPDOWN, SET_LAYOUT_MODE, - CHANGE_VIEWER_LAYOUT, VALUE_CHANGE, ImagePlotCntlr.CHANGE_ACTIVE_PLOT_VIEW, CHART_ADD + CHANGE_VIEWER_LAYOUT, VALUE_CHANGE, CHANGE_ACTIVE_PLOT_VIEW, CHART_ADD ]); /** @@ -257,7 +258,7 @@ export function* lcManager(params={}) { case TBL_RESULTS_ACTIVE : newLayoutInfo = handleTableActive(newLayoutInfo, action); break; - case ImagePlotCntlr.CHANGE_ACTIVE_PLOT_VIEW: + case CHANGE_ACTIVE_PLOT_VIEW: newLayoutInfo = handlePlotActive(newLayoutInfo, action); break; case CHART_ADD: @@ -727,7 +728,7 @@ export function setupImages(layoutInfo, invokedBy=TABLE_FETCH){ } const viewer = getViewer(getMultiViewRoot(), LC.IMG_VIEWER_ID); - const count= getLayoutDetails(getMultiViewRoot(), LC.IMG_VIEWER_ID)?.count ?? converterData.defaultImageCount + const count= getLayoutDetails(getMultiViewRoot(), LC.IMG_VIEWER_ID)?.count ?? converterData.defaultImageCount; var vr = visRoot(); @@ -743,7 +744,6 @@ export function setupImages(layoutInfo, invokedBy=TABLE_FETCH){ const newPlotIdAry = makePlotIds(tableModel.highlightedRow, tableModel.totalRows, count); const maxPlotIdAry = makePlotIds(tableModel.highlightedRow, tableModel.totalRows, LC.MAX_IMAGE_CNT); const cutoutSize = getCutoutSize(layoutInfo); - const uploadFilename = getUploadFileName(layoutInfo) || ''; try { newPlotIdAry.forEach((plotId) => { @@ -781,7 +781,7 @@ export function setupImages(layoutInfo, invokedBy=TABLE_FETCH){ .filter((pv) => pv.plotId.startsWith(plotIdRoot)) .filter((pv) => pv.plotId !== vr.mpwWcsPrimId) .filter((pv) => !maxPlotIdAry.includes(pv.plotId)) - .forEach((pv) => dispatchDeletePlotView({plotId: pv.plotId, holdWcsMatch: true})); + .forEach((pv) => dispatchDeletePlotView({plotId: pv.plotId})); // Decide whether or not to show images, mission specific: const imagesShown = converterData.shouldImagesBeDisplayed(layoutInfo); diff --git a/src/firefly/js/threadWorker/WorkerAccess.js b/src/firefly/js/threadWorker/WorkerAccess.js index 14ee9ffdfb..784f62b9e0 100644 --- a/src/firefly/js/threadWorker/WorkerAccess.js +++ b/src/firefly/js/threadWorker/WorkerAccess.js @@ -1,4 +1,4 @@ -import {dispatchPlotProgressUpdate} from '../visualize/ImagePlotCntlr'; +import {dispatchPlotProgressUpdate} from '../visualize/ImagePlotDispatch'; import Worker from './firefly-thread.worker.js'; import {uniqueId} from 'lodash'; import {Logger} from '../util/Logger.js'; diff --git a/src/firefly/js/ui/ActionsDropDownButton.jsx b/src/firefly/js/ui/ActionsDropDownButton.jsx index 8589624580..d5216297d8 100644 --- a/src/firefly/js/ui/ActionsDropDownButton.jsx +++ b/src/firefly/js/ui/ActionsDropDownButton.jsx @@ -10,9 +10,8 @@ import {useStoreConnector} from './SimpleComponent.jsx'; import {DropDownVerticalSeparator, ToolbarButton} from './ToolbarButton.jsx'; import {getSearchTypeDesc, getValidSize, SearchTypes} from '../core/ClickToAction.js'; import CysConverter from '../visualize/CsysConverter.js'; -import {visRoot} from '../visualize/ImagePlotCntlr.js'; import {PlotAttribute} from '../visualize/PlotAttribute.js'; -import {getActivePlotView, primePlot} from '../visualize/PlotViewUtil.js'; +import {currentP, primePlot} from '../visualize/PlotViewUtil.js'; import {showSearchRefinementTool} from '../visualize/SearchRefinementTool.jsx'; import {convertWpAryToStr, getDetailsFromSelection, markOutline} from '../visualize/ui/VisualSearchUtils.js'; import {formatWorldPt} from '../visualize/ui/WorldPtFormat.jsx'; @@ -43,7 +42,7 @@ function doExecute(sa,cenWpt,radius,cornerStr,table) { case SearchTypes.pointRadius: const valRadius= getValidSize(sa, radius); sa.execute(sa, cenWpt, valRadius, cornerStr); - markOutline(sa, primePlot(visRoot())?.plotId,{ wp:cenWpt, radius:valRadius, polyStr:cornerStr}); + markOutline(sa, currentP().plotId,{ wp:cenWpt, radius:valRadius, polyStr:cornerStr}); break; case SearchTypes.point: case SearchTypes.point_table_only: @@ -70,7 +69,7 @@ function isSupported(sa,cenWpt,radius,cornerStr,table) { function SearchDropDown({searchActions, buttonRef, spacial, tbl_id}) { - const pv = useStoreConnector(() => spacial? getActivePlotView(visRoot()) : undefined); + const pv = useStoreConnector(() => spacial? currentP().pv : undefined); const plot= primePlot(pv); const table= tbl_id && getTblById(tbl_id); const {cenWpt, radius, corners, cone} = spacial ? @@ -99,10 +98,8 @@ function SearchDropDown({searchActions, buttonRef, spacial, tbl_id}) { const buttons= sActions.map((sa,idx) => { const text = getSearchTypeDesc({sa, wp:cenWpt, size:radius, areaPtsLength:corners?.length, tbl_id}); - let useSep = false; if (lastGroupId && sa.groupId !== lastGroupId && idx!==sActions.length-1) { lastGroupId = sa.groupId; - useSep = true; } if (!lastGroupId) lastGroupId = sa.groupId; return ( diff --git a/src/firefly/js/ui/CatalogSearchMethodType.jsx b/src/firefly/js/ui/CatalogSearchMethodType.jsx index a60c853cba..ed0edd9fb6 100644 --- a/src/firefly/js/ui/CatalogSearchMethodType.jsx +++ b/src/firefly/js/ui/CatalogSearchMethodType.jsx @@ -24,9 +24,8 @@ import {FieldGroup, FieldGroupCtx} from './FieldGroup.jsx'; import {useFieldGroupValue, useFieldGroupWatch} from './SimpleComponent'; import CsysConverter from '../visualize/CsysConverter.js'; -import {primePlot, getActivePlotView, getFoV} from '../visualize/PlotViewUtil.js'; +import {primePlot, getFoV, currentP} from '../visualize/PlotViewUtil.js'; import {makeImagePt, makeWorldPt, makeScreenPt, makeDevicePt, parseWorldPt} from '../visualize/Point.js'; -import {visRoot} from '../visualize/ImagePlotCntlr.js'; import {getValueInScreenPixel} from '../visualize/draw/ShapeDataObj.js'; import {hasWCSProjection} from '../visualize/PlotViewUtil'; @@ -61,8 +60,7 @@ export function CatalogSearchMethodTypeImpl({polygonDefWhenPlot, withPos=true, s if (getFld('conesize')?.max!==max) setFld('conesize', {min:1/3600,max}); }, [coneSize,spatial]); - const plot = primePlot(visRoot()); - const polyIsDef= polygonDefWhenPlot && plot; + const polyIsDef= polygonDefWhenPlot && currentP().plot; const searchType = withPos ? spatial : SpatialMethod['All Sky'].value; return ( @@ -230,8 +228,7 @@ function SizeArea({groupKey, searchType, imageCornerCalc}) { const {setVal,getVal} = useContext(FieldGroupCtx); const onChangeToPolygonMethod = () => { - const pv = getActivePlotView(visRoot()); - const plot = primePlot(pv); + const {plot,pv}= currentP(); if (!plot) return; const cornerCalcV = getVal('imageCornerCalc'); if ((!cornerCalcV || cornerCalcV === 'image' || cornerCalcV === 'viewport' || cornerCalcV === 'area-selection')) { @@ -318,8 +315,7 @@ export function PolygonDataArea({imageCornerCalc, initValue='', {label: 'Custom', value: 'user'} ]; - const pv= getActivePlotView(visRoot()); - var plot = primePlot(pv); + const {plot,pv}= currentP(); if(isHiPS(plot)){ cornerTypeOps = [ diff --git a/src/firefly/js/ui/ChartSelectDropdown.jsx b/src/firefly/js/ui/ChartSelectDropdown.jsx index 3587ab7b87..b2c0fbce93 100644 --- a/src/firefly/js/ui/ChartSelectDropdown.jsx +++ b/src/firefly/js/ui/ChartSelectDropdown.jsx @@ -7,9 +7,9 @@ import {string} from 'prop-types'; import {Stack, Typography} from '@mui/joy'; import {getNumericCols} from '../charts/ChartUtil.js'; +import {DEFAULT_PLOT2D_VIEWER_ID} from '../visualize/VisConst'; import {ChartSelectPanel, CHART_ADDNEW} from './../charts/ui/ChartSelectPanel.jsx'; import {getActiveViewerItemId} from '../charts/ui/MultiChartViewer.jsx'; -import {DEFAULT_PLOT2D_VIEWER_ID} from '../visualize/MultiViewCntlr.js'; import CompleteButton from './CompleteButton.jsx'; import {dispatchHideDropDown} from '../core/LayoutCntlr.js'; diff --git a/src/firefly/js/ui/CutoutSizeDialog.jsx b/src/firefly/js/ui/CutoutSizeDialog.jsx index 15e23e582f..1bccca0964 100644 --- a/src/firefly/js/ui/CutoutSizeDialog.jsx +++ b/src/firefly/js/ui/CutoutSizeDialog.jsx @@ -10,9 +10,9 @@ import {dispatchShowDialog, dispatchHideDialog} from '../core/ComponentCntlr.js' import {MetaConst} from '../data/MetaConst'; import {FixedPtControl} from '../drawingLayers/FixedPtControl'; import {getMetaEntry} from '../tables/TableUtil'; -import {dispatchChangePointSelection, visRoot} from '../visualize/ImagePlotCntlr'; +import {dispatchChangePointSelection} from '../visualize/ImagePlotDispatch'; import {PlotAttribute} from '../visualize/PlotAttribute'; -import {getActivePlotView, primePlot} from '../visualize/PlotViewUtil'; +import {currentP} from '../visualize/PlotViewUtil'; import {isValidPoint, parseWorldPt} from '../visualize/Point'; import {formatWorldPt, formatWorldPtToString} from '../visualize/ui/WorldPtFormat'; import {makeFoVString} from '../visualize/ZoomUtil'; @@ -188,7 +188,7 @@ function CutoutSizePanel({showingCutout,cutoutDefSizeDeg,pixelBasedCutout,dataPr const activeWp= useStoreConnector(() => { if (overrideCutoutWpt) return overrideCutoutWpt; - const plot= primePlot(visRoot()); + const {plot}= currentP(); if (!plot) return; const {pt}=plot.attributes[PlotAttribute.ACTIVE_POINT] ?? {}; return pt; @@ -388,7 +388,7 @@ const OverrideTargetFeedback= ({overrideCutoutWpt, showingCutout}) => ( {`${showingCutout?'Cutouts':'Full images'} include position:`} {formatWorldPt(overrideCutoutWpt,5,false)} - {} + {} ); diff --git a/src/firefly/js/ui/DefaultSearchActions.js b/src/firefly/js/ui/DefaultSearchActions.js index 4bdf7505b6..b2717713eb 100644 --- a/src/firefly/js/ui/DefaultSearchActions.js +++ b/src/firefly/js/ui/DefaultSearchActions.js @@ -9,8 +9,8 @@ import {extractDatalinkTable} from '../metaConvert/TableDataProductUtils'; import {makeVOCatalogRequest} from '../tables/TableRequestUtil.js'; import {dispatchTableSearch, dispatchTableUiUpdate, dispatchTableUpdate} from '../tables/TablesCntlr.js'; import {tokenSub} from '../util/WebUtil'; +import {DEFAULT_FITS_VIEWER_ID} from '../visualize/VisConst'; import { findTableCenterColumns, isFormatDataLink, isObsCoreLike } from '../voAnalyzer/TableAnalysis.js'; -import {DEFAULT_FITS_VIEWER_ID} from '../visualize/MultiViewCntlr.js'; import {getTableModel} from '../voAnalyzer/VoCoreUtils'; import {getServiceDescriptors, isDataLinkServiceDesc} from '../voAnalyzer/VoDataLinkServDef'; import {setMultiSearchPanelTab} from './MultiSearchPanel.jsx'; diff --git a/src/firefly/js/ui/FileUploadProcessor.jsx b/src/firefly/js/ui/FileUploadProcessor.jsx index 6124e016d4..66e48877cd 100644 --- a/src/firefly/js/ui/FileUploadProcessor.jsx +++ b/src/firefly/js/ui/FileUploadProcessor.jsx @@ -14,12 +14,12 @@ import { TABLES, UWS } from 'firefly/ui/FileUploadUtil'; import {showInfoPopup, showYesNoPopup} from 'firefly/ui/PopupUtil'; -import { - dispatchCreateImageLineBasedFootprintLayer, dispatchCreateRegionLayer, getDlAry -} from 'firefly/visualize/DrawLayerCntlr'; import {getAppHiPSForMoc, isMOCFitsFromUploadAnalsysis} from 'firefly/visualize/HiPSMocUtil'; -import {dispatchPlotImage, visRoot} from 'firefly/visualize/ImagePlotCntlr'; -import {getAViewFromMultiView, getMultiViewRoot, IMAGE} from 'firefly/visualize/MultiViewCntlr'; +import {getAViewFromMultiView, getMultiViewRoot} from 'firefly/visualize/MultiViewCntlr'; +import {dispatchCreateImageLineBasedFootprintLayer, dispatchCreateRegionLayer} from '../visualize/DrawLayerDispatch'; +import {dispatchPlotImage} from '../visualize/ImagePlotDispatch'; +import {IMAGE} from '../visualize/VisConst'; +import {getDlAry, visRoot} from '../visualize/VisStoreRoots'; import {PlotAttribute} from 'firefly/visualize/PlotAttribute'; import {getDrawLayersByType, getPlotViewAry, primePlot} from 'firefly/visualize/PlotViewUtil'; import RangeValues from 'firefly/visualize/RangeValues'; @@ -31,7 +31,6 @@ import {dispatchHideDropDown, dispatchShowDropDown} from '../core/LayoutCntlr'; import {dispatchAddActionWatcher} from '../core/MasterSaga'; import {getIntHeaderFromAnalysis, getTableHeaderFromAnalysis} from '../metaConvert/PartAnalyzer.js'; import {upload} from '../rpc/CoreServices'; -import {getAllSelectedIndexes} from '../tables/HpxIndexCntlr'; import {getHttpErrorMessage} from '../util/HttpErrorMessage'; import {getStatusFromFetchError} from '../util/WebUtil'; @@ -290,6 +289,7 @@ export function determineValidity(acceptList, uniqueTypes, summaryModel, summary const unsupportedIndexes= allIdxs.filter( (i) => report.parts[i].unsupported); if (allIdxs.length && unsupportedIndexes.length === allIdxs.length) { + const unsupportedSingleErr= {errorMsg: 'unsupported image type'}; if (allIdxs.length === 1) { const reason= report.parts[allIdxs[0]]?.unsupportedReason; const errorMsg= reason ? errorObj.unsupportedSingleErr.errorMsg + ': ' + reason : unsupportedSingleErr.errorMsg; diff --git a/src/firefly/js/ui/FitsDownloadDialog.jsx b/src/firefly/js/ui/FitsDownloadDialog.jsx index bdf2163e02..b01f78deac 100644 --- a/src/firefly/js/ui/FitsDownloadDialog.jsx +++ b/src/firefly/js/ui/FitsDownloadDialog.jsx @@ -15,9 +15,8 @@ import {FieldGroup} from './FieldGroup.jsx'; import DialogRootContainer from './DialogRootContainer.jsx'; import {PopupPanel} from './PopupPanel.jsx'; import {getFieldVal} from '../fieldGroup/FieldGroupUtils.js'; -import { primePlot, getActivePlotView, getAllCanvasLayersForPlot, isThreeColor } from '../visualize/PlotViewUtil.js'; +import {primePlot, getAllCanvasLayersForPlot, isThreeColor, currentP} from '../visualize/PlotViewUtil.js'; import {Band} from '../visualize/Band.js'; -import {visRoot} from '../visualize/ImagePlotCntlr.js'; import {isImage} from '../visualize/WebPlot.js'; import {makeRegionsFromPlot} from '../visualize/region/RegionDescription.js'; import {saveDS9RegionFile} from '../rpc/PlotServicesJson.js'; @@ -109,9 +108,8 @@ const MakeFileOptions = ({plot,colors,hasOperation,threeC}) => { }; const FitsDownloadDialogForm= memo( ({isWs, popupId, groupKey}) => { - const pv= getActivePlotView(visRoot()); + const {pv,plot}= currentP(); const {tableCnt}= getResultCounts(); - const plot = primePlot(pv); const colors = getColors(plot); const threeC = isThreeColor(plot); const hasOperation = plot?.plotState.hasOperation(Operation.CROP) ?? false; diff --git a/src/firefly/js/ui/FitsRotationDialog.jsx b/src/firefly/js/ui/FitsRotationDialog.jsx index 3310ade856..74cfd70cb9 100644 --- a/src/firefly/js/ui/FitsRotationDialog.jsx +++ b/src/firefly/js/ui/FitsRotationDialog.jsx @@ -8,8 +8,8 @@ import {isEastLeftOfNorth} from '../visualize/WebPlotAnalysis'; import CompleteButton from './CompleteButton.jsx'; import DialogRootContainer from './DialogRootContainer.jsx'; import {PopupPanel} from './PopupPanel.jsx'; -import {getActivePlotView, primePlot} from '../visualize/PlotViewUtil.js'; -import {visRoot, dispatchRotate} from '../visualize/ImagePlotCntlr.js'; +import {currentP, primePlot} from '../visualize/PlotViewUtil.js'; +import {dispatchRotate} from '../visualize/ImagePlotDispatch'; import {SimpleLayerOnOffButton} from '../visualize/ui/SimpleLayerOnOffButton'; import {RotateType} from '../visualize/PlotState.js'; import {StateInputField} from './StatedInputfield'; @@ -50,7 +50,7 @@ const marks = [ { label: '0', value: 0 }, { label: '45', value: 45 }, { label: ' ]; function FitsRotationImmediatePanel() { - const pv = useStoreConnector(() => getActivePlotView(visRoot())); + const pv = useStoreConnector(() => currentP().pv); useEffect(() => { (!pv || !isImage(primePlot(pv))) && dispatchHideDialog(DIALOG_ID); diff --git a/src/firefly/js/ui/HiPSImageSelect.jsx b/src/firefly/js/ui/HiPSImageSelect.jsx index 61e9575397..0c59576b9c 100644 --- a/src/firefly/js/ui/HiPSImageSelect.jsx +++ b/src/firefly/js/ui/HiPSImageSelect.jsx @@ -12,7 +12,7 @@ import { } from '../visualize/HiPSListUtil.js'; import {ValidationField} from './ValidationField.jsx'; import {getCellValue, getColumnValues, getTblById, onTableLoaded} from '../tables/TableUtil.js'; -import {DEFAULT_FITS_VIEWER_ID} from '../visualize/MultiViewCntlr.js'; +import {DEFAULT_FITS_VIEWER_ID} from '../visualize/VisConst'; import WebPlotRequest from '../visualize/WebPlotRequest.js'; import {parseWorldPt} from '../visualize/Point.js'; import {dispatchTableFetch, dispatchTableHighlight} from '../tables/TablesCntlr.js'; @@ -21,13 +21,13 @@ import {showInfoPopup} from './PopupUtil.jsx'; import {CheckboxGroupInputField} from './CheckboxGroupInputField.jsx'; import {useStoreConnector} from './SimpleComponent.jsx'; import {getFieldVal} from '../fieldGroup/FieldGroupUtils.js'; -import {dispatchChangeHiPS, visRoot} from '../visualize/ImagePlotCntlr.js'; +import {dispatchChangeHiPS} from '../visualize/ImagePlotDispatch'; import {PopupPanel} from './PopupPanel.jsx'; import DialogRootContainer from './DialogRootContainer.jsx'; import {dispatchHideDialog, dispatchShowDialog} from '../core/ComponentCntlr.js'; import {FormPanel} from './FormPanel.jsx'; import {FieldGroup, FieldGroupCtx} from './FieldGroup.jsx'; -import {primePlot} from '../visualize/PlotViewUtil.js'; +import {primePlot, currentP} from '../visualize/PlotViewUtil.js'; import {BLANK_HIPS_URL} from '../visualize/WebPlot.js'; import {createHiPSMocLayer} from 'firefly/visualize/task/PlotHipsTask.js'; import {getAppOptions} from 'firefly/core/AppDataCntlr.js'; @@ -110,22 +110,15 @@ export function showHiPSSurveysPopup(pv, moc= false) { if (resultSuccess(request)) dispatchHideDialog(DIALOG_ID); } else { - const rootUrl = getHipsUrl(); - if (rootUrl) { - const plot = pv ? primePlot(pv) : primePlot(visRoot()); - // update the table highlight of the other one which is not shown in table panel - moc ? createHiPSMocLayer({ - ivoid: getIvoaId(), - title: getTitle(), - hipsUrl: rootUrl, - mocFile: rootUrl.toLowerCase().endsWith('fits') ? '' : undefined, - plot: primePlot(pv), - visible: true - } ) : - dispatchChangeHiPS({plotId: plot.plotId, hipsUrlRoot: rootUrl} - ); - dispatchHideDialog(DIALOG_ID); - } + const hipsUrl = getHipsUrl(); + if (hipsUrl) return; + const plot = pv ? primePlot(pv) : currentP().plot; + moc + ? createHiPSMocLayer({ + ivoid: getIvoaId(), title: getTitle(), hipsUrl, plot, visible: true, + mocFile: hipsUrl.toLowerCase().endsWith('fits') ? '' : undefined}) + : dispatchChangeHiPS({plotId: plot.plotId, hipsUrlRoot: hipsUrl} ); + dispatchHideDialog(DIALOG_ID); } }; diff --git a/src/firefly/js/ui/PointShapeSizePicker.jsx b/src/firefly/js/ui/PointShapeSizePicker.jsx index 1e1f224230..930d41c6ac 100644 --- a/src/firefly/js/ui/PointShapeSizePicker.jsx +++ b/src/firefly/js/ui/PointShapeSizePicker.jsx @@ -10,7 +10,8 @@ import {PopupPanel} from './PopupPanel.jsx'; import {DrawSymbol} from '../visualize/draw/DrawSymbol.js'; import DrawUtil from '../visualize/draw/DrawUtil.js'; import {drawOnCanvas} from '../visualize/ui/DrawLayerUIComponents.jsx'; -import {dispatchChangeDrawingDef, getDlAry} from '../visualize/DrawLayerCntlr.js'; +import {dispatchChangeDrawingDef} from '../visualize/DrawLayerDispatch'; +import {getDlAry} from '../visualize/VisStoreRoots'; import CompleteButton from './CompleteButton.jsx'; import DialogRootContainer from './DialogRootContainer.jsx'; import {RadioGroupInputFieldView} from './RadioGroupInputFieldView.jsx'; @@ -18,7 +19,7 @@ import {InputFieldView} from './InputFieldView.jsx'; import {SimpleCanvas} from '../visualize/draw/SimpleCanvas.jsx'; import {getDrawLayersByDisplayGroup} from '../visualize/PlotViewUtil.js'; import Color from '../util/Color.js'; -import {HelpIcon} from '../ui/HelpIcon.jsx'; +import {HelpIcon} from './HelpIcon'; import {useStoreConnector} from 'firefly/ui/SimpleComponent'; diff --git a/src/firefly/js/ui/ZoomOptionsPopup.jsx b/src/firefly/js/ui/ZoomOptionsPopup.jsx index 9385f92731..5d9566a7f5 100644 --- a/src/firefly/js/ui/ZoomOptionsPopup.jsx +++ b/src/firefly/js/ui/ZoomOptionsPopup.jsx @@ -6,9 +6,10 @@ import React, {useEffect} from 'react'; import {dispatchShowDialog, dispatchHideDialog} from '../core/ComponentCntlr.js'; import DialogRootContainer from './DialogRootContainer.jsx'; import {PopupPanel} from './PopupPanel.jsx'; -import {getActivePlotView, getFoV, primePlot} from '../visualize/PlotViewUtil.js'; -import {visRoot, dispatchZoom} from '../visualize/ImagePlotCntlr.js'; -import {imageLevels, UserZoomTypes, makeFoVString} from '../visualize/ZoomUtil'; +import {getFoV, primePlot, currentP} from '../visualize/PlotViewUtil.js'; +import {dispatchZoom} from '../visualize/ImagePlotDispatch'; +import {UserZoomTypes} from '../visualize/VisConst'; +import {imageLevels, makeFoVString} from '../visualize/ZoomUtil'; import {ToolbarButton} from './ToolbarButton.jsx'; import {useStoreConnector} from 'firefly/ui/SimpleComponent.jsx'; @@ -19,9 +20,9 @@ export function showZoomOptionsPopup() { } const ZoomOptionsPopup = () => { - const pv= useStoreConnector( () => getActivePlotView(visRoot())); - useEffect(() => void (!primePlot(pv) && dispatchHideDialog('zoomOptionsDialog')), [pv]); - return primePlot(pv) ? :
; + const {pv,plot}= useStoreConnector( () => currentP()); + useEffect(() => void (!plot && dispatchHideDialog('zoomOptionsDialog')), [pv]); + return plot ? :
; }; const ZoomOptionsPopupForm= ({pv}) => ( diff --git a/src/firefly/js/ui/dynamic/DLGeneratedDropDown.js b/src/firefly/js/ui/dynamic/DLGeneratedDropDown.js index 2e0757e683..99a9e364d1 100644 --- a/src/firefly/js/ui/dynamic/DLGeneratedDropDown.js +++ b/src/firefly/js/ui/dynamic/DLGeneratedDropDown.js @@ -2,7 +2,7 @@ import {Box, Sheet, Skeleton, Stack, Typography} from '@mui/joy'; import {isArray, isEmpty} from 'lodash'; import {bool, func, object, shape, string} from 'prop-types'; import React, {useEffect, useState} from 'react'; -import {makeWorldPt, visRoot} from '../../api/ApiUtilImage.jsx'; +import {makeWorldPt, pointEquals} from '../../visualize/Point.js'; import {dispatchActiveTarget} from '../../core/AppDataCntlr.js'; import {getComponentState} from '../../core/ComponentCntlr.js'; import {MetaConst} from '../../data/MetaConst.js'; @@ -17,11 +17,10 @@ import {makeSearchOnce, toBoolean} from '../../util/WebUtil.js'; import CoordSys from '../../visualize/CoordSys.js'; import {ensureHiPSInit} from '../../visualize/HiPSListUtil.js'; import {getHiPSZoomLevelForFOV} from '../../visualize/HiPSUtil.js'; -import {dispatchChangeCenterOfProjection, dispatchZoom} from '../../visualize/ImagePlotCntlr.js'; -import {getPlotViewById, primePlot} from '../../visualize/PlotViewUtil.js'; -import {pointEquals} from '../../visualize/Point.js'; +import {dispatchChangeCenterOfProjection, dispatchZoom} from '../../visualize/ImagePlotDispatch'; +import {currentP} from '../../visualize/PlotViewUtil.js'; import {isHiPS} from '../../visualize/WebPlot.js'; -import {UserZoomTypes} from '../../visualize/ZoomUtil.js'; +import {UserZoomTypes} from '../../visualize/VisConst'; import {FieldGroup} from '../FieldGroup.jsx'; import {showInfoPopup} from '../PopupUtil.jsx'; import {useStoreConnector} from '../SimpleComponent.jsx'; @@ -387,7 +386,7 @@ function DLGeneratedTableSearch({currentTblId, qAna, groupKey, initArgs, sideBar * @param {Array.} fieldDefAry */ function alignHiPS(currentTblId, qAna, groupKey, fieldDefAry) { - const plot= primePlot(visRoot(),HIPS_PLOT_ID); + const {plot,pv}= currentP(HIPS_PLOT_ID); if (!currentTblId || !isHiPS(plot) || !getCisxUI(qAna).length) return; // probably init is not complete, return const request= getFieldGroupResults(groupKey); // todo: this might not be right, there might be an array of field groups @@ -403,7 +402,6 @@ function alignHiPS(currentTblId, qAna, groupKey, fieldDefAry) { const centerProjPt= makeWorldPt(raStr, decStr, coordSys); if (!centerProjPt) return; dispatchChangeCenterOfProjection({plotId:HIPS_PLOT_ID, centerProjPt}); - const pv= getPlotViewById(visRoot(),HIPS_PLOT_ID); if (!fov || !pv) return; const MIN_FOV_SIZE= .0025; // 9 arcsec - minimum fov for initial size const level= getHiPSZoomLevelForFOV(pv,Math.max(fov,MIN_FOV_SIZE)); diff --git a/src/firefly/js/ui/tap/SpatialSearch.jsx b/src/firefly/js/ui/tap/SpatialSearch.jsx index 13d7e197ba..524ad024fc 100644 --- a/src/firefly/js/ui/tap/SpatialSearch.jsx +++ b/src/firefly/js/ui/tap/SpatialSearch.jsx @@ -11,9 +11,8 @@ import {findCenterColumnsByColumnsModel} from '../../voAnalyzer/ColumnsModelInfo import {findTableCenterColumns} from '../../voAnalyzer/TableAnalysis.js'; import {posCol, UCDCoord} from '../../voAnalyzer/VoConst.js'; import CoordinateSys from '../../visualize/CoordSys.js'; -import {visRoot} from '../../visualize/ImagePlotCntlr.js'; import {PlotAttribute} from '../../visualize/PlotAttribute.js'; -import {getActivePlotView, primePlot} from '../../visualize/PlotViewUtil.js'; +import {currentP} from '../../visualize/PlotViewUtil.js'; import {makeWorldPt, parseWorldPt} from '../../visualize/Point.js'; import {VisualTargetPanel} from '../../visualize/ui/TargetHiPSPanel.jsx'; import {convertCelestial} from '../../visualize/VisUtil.js'; @@ -200,8 +199,7 @@ export function SpatialSearch({sx, cols, serviceUrl, serviceLabel, serviceId, co const onChangeToPolygonMethod = () => { if (!handleHiPSConnection) return; - const pv = getActivePlotView(visRoot()); - const plot = primePlot(visRoot(),pv); + const {pv,plot}= currentP(); if (!plot) return; const cornerCalcV = getVal(cornerCalcType); if ((!cornerCalcV || cornerCalcV === 'image' || cornerCalcV === 'viewport' || cornerCalcV === 'area-selection')) { diff --git a/src/firefly/js/visualize/ChangePrime.js b/src/firefly/js/visualize/ChangePrime.js index 7bf9d6038c..0f50d5f4ac 100644 --- a/src/firefly/js/visualize/ChangePrime.js +++ b/src/firefly/js/visualize/ChangePrime.js @@ -2,11 +2,11 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import ImagePlotCntlr, {IMAGE_PLOT_KEY, dispatchZoom, dispatchProcessScroll} from './ImagePlotCntlr.js'; -import {getPlotViewById, primePlot} from './PlotViewUtil.js'; +import {dispatchProcessScroll, dispatchZoom} from './ImagePlotDispatch'; +import {IMAGE_PLOT_KEY, UserZoomTypes, ZOOM_IMAGE} from './VisConst'; +import {hasWCSProjection, getPlotViewById, primePlot} from './PlotViewUtil.js'; import {getPixScaleArcSec, getScreenPixScaleArcSec} from './WebPlot.js'; -import {hasWCSProjection} from './PlotViewUtil.js'; -import {UserZoomTypes, getZoomLevelForScale} from './ZoomUtil.js'; +import {getZoomLevelForScale} from './ZoomUtil.js'; import {CysConverter} from './CsysConverter.js'; import {makeScreenPt} from './Point.js'; import {dispatchAddActionWatcher} from '../core/MasterSaga'; @@ -21,7 +21,6 @@ function matcher(oldP,newP) { }; } - function getZoomDecision(oldP,newP) { const m= matcher(oldP,newP); if (m.isProjection) { @@ -64,7 +63,7 @@ export function changePrime(rawAction, dispatcher, getState) { function zoomCompleteWatch(action, cancelSelf, {plotId,scrollToImagePt},dispatch,getState) { if (action.payload.plotId===plotId) { const visRoot= getState()[IMAGE_PLOT_KEY]; - (action.type===ImagePlotCntlr.ZOOM_IMAGE) && changeScrollToImagePt(visRoot,plotId,scrollToImagePt); + (action.type===ZOOM_IMAGE) && changeScrollToImagePt(visRoot,plotId,scrollToImagePt); cancelSelf(); } } @@ -76,7 +75,7 @@ function changeScrollToImagePt(visRoot, plotId, scrollToImagePt) { } const addWatcher= (plotId,scrollToImagePt) => dispatchAddActionWatcher( { - callback:zoomCompleteWatch, params:{plotId,scrollToImagePt}, actions:[ImagePlotCntlr.ZOOM_IMAGE] }); + callback:zoomCompleteWatch, params:{plotId,scrollToImagePt}, actions:[ZOOM_IMAGE] }); function checkZoom(plotId, oldP, newP, scrollToImagePt, visRoot) { diff --git a/src/firefly/js/visualize/CoordUtil.js b/src/firefly/js/visualize/CoordUtil.js index b2ce6e16f7..19049c51a0 100644 --- a/src/firefly/js/visualize/CoordUtil.js +++ b/src/firefly/js/visualize/CoordUtil.js @@ -1,5 +1,3 @@ -/*eslint no-empty:0*/ -/*eslint quotes:0*/ import {sprintf} from '../externalSource/sprintf'; import {CoordinateSys} from './CoordSys.js'; import {isDigit} from 'firefly/util/MathUtil.js'; @@ -7,7 +5,7 @@ import {isDigit} from 'firefly/util/MathUtil.js'; /** * This class provides conversion of user's * coordinate string to a double - * Translated to javascript from java from Rick Ebert's coord.c + * Translated to JavaScript from java from Rick Ebert's coord.c * * April 10, 2001 * Copied from the original Coord.java, modified to provide the convenient @@ -118,13 +116,13 @@ const sex2dd = function (coordstr, islat, isequ) { const sepJoin= sep.join(''); // join all the separators for easier testing if (part.length===3) { if (sepJoin==='hms' || sepJoin==='hm ') degrees = 0; - else if (sepJoin==='dms' || sepJoin==='dm ' || sepJoin===`d'"` || sepJoin===`d' `) degrees = 1; + else if (sepJoin==='dms' || sepJoin==='dm ' || sepJoin===`d'"` || sepJoin===`d' `) degrees = 1;// eslint-disable-line @stylistic/js/quotes else if (sepJoin===':: ' || sepJoin===' ') degrees = -1; else throw INVALID_SEPARATOR; } else if (part.length===2) { if (sepJoin==='hm' || sepJoin==='h ') degrees = 0; - else if (sepJoin==='dm' || sepJoin==='d ' || sepJoin===`d'` || sepJoin===`'"` || sepJoin===`' `) degrees = 1; + else if (sepJoin==='dm' || sepJoin==='d ' || sepJoin===`d'` || sepJoin===`'"` || sepJoin===`' `) degrees = 1;// eslint-disable-line @stylistic/js/quotes else if (sepJoin==='ms' || sepJoin==='m ' || sepJoin===': ' || sepJoin===' ') degrees = -1; else throw INVALID_SEPARATOR; } @@ -139,7 +137,7 @@ const sex2dd = function (coordstr, islat, isequ) { isdec= !(isequ && !islat); } else if (sep[0] ==='m' || sep[0] ==='s') { degrees = -1; - } else if (sep[0] ===`'` || sep[0] ==='"') { + } else if (sep[0] ===`'` || sep[0] ==='"') {// eslint-disable-line @stylistic/js/quotes degrees = 1; } else { throw INVALID_SEPARATOR; @@ -319,7 +317,8 @@ export function parseDBIdToCoord(s) { try { return {lon:convertStringToLon(lon, cSys),lat:convertStringToLat(lat, cSys),cSys}; } - catch (e) { + + catch (e) { // eslint-disable-line no-unused-vars return false; } } @@ -334,7 +333,7 @@ const validLon = (hms, coordSystem) => { try { convertStringToLon(hms, coordSystem); return true; - } catch (e) { + } catch (e) { // eslint-disable-line no-unused-vars return false; } }; diff --git a/src/firefly/js/visualize/DrawLayerCntlr.js b/src/firefly/js/visualize/DrawLayerCntlr.js index 7ab761d6d8..3214bf8546 100644 --- a/src/firefly/js/visualize/DrawLayerCntlr.js +++ b/src/firefly/js/visualize/DrawLayerCntlr.js @@ -2,147 +2,44 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import {flux} from '../core/ReduxFlux.js'; -import Enum from 'enum'; import { - getAllPlotViewIdByOverlayLock, - getConnectedPlotsIds, - getDrawLayerById, - getPlotViewById, - getPlotViewIdListInOverlayGroup -} from './PlotViewUtil.js'; -import ImagePlotCntlr, {visRoot} from './ImagePlotCntlr.js'; -import DrawLayerReducer from './reducer/DrawLayerReducer.js'; -import {flatten, isEmpty, union, uniqBy, without} from 'lodash'; -import {clone, toBoolean} from '../util/WebUtil.js'; + extractLineToolEndActionCreator, extractLineToolStartActionCreator +} from 'firefly/drawingLayers/ExtractLineTool.js'; +import {isEmpty, union, without} from 'lodash'; -import {selectAreaEndActionCreator} from '../drawingLayers/SelectArea.js'; +import {REINIT_APP} from '../core/CoreConst'; +import {dispatchAddActionWatcher} from '../core/MasterSaga.js'; import {distanceToolEndActionCreator} from '../drawingLayers/DistanceTool.js'; + import { - extractLineToolEndActionCreator, - extractLineToolStartActionCreator -} from 'firefly/drawingLayers/ExtractLineTool.js'; + footprintCreateLayerActionCreator, footprintEndActionCreator, footprintMoveActionCreator, + footprintStartActionCreator +} from '../drawingLayers/FootprintTool.js'; import { - markerToolCreateLayerActionCreator, - markerToolEndActionCreator, - markerToolMoveActionCreator, + markerToolCreateLayerActionCreator, markerToolEndActionCreator, markerToolMoveActionCreator, markerToolStartActionCreator } from '../drawingLayers/MarkerTool.js'; -import { - regionCreateLayerActionCreator, - regionDeleteLayerActionCreator, - regionUpdateEntryActionCreator -} from './region/RegionTask.js'; +import {selectAreaEndActionCreator} from '../drawingLayers/SelectArea.js'; +import {getConnectedPlotsIds, getDrawLayerById} from './PlotViewUtil.js'; +import DrawLayerReducer from './reducer/DrawLayerReducer.js'; import { - footprintCreateLayerActionCreator, - footprintEndActionCreator, - footprintMoveActionCreator, - footprintStartActionCreator -} from '../drawingLayers/FootprintTool.js'; -import {dispatchAddActionWatcher} from '../core/MasterSaga.js'; + regionCreateLayerActionCreator, regionDeleteLayerActionCreator, regionUpdateEntryActionCreator +} from './region/RegionTask.js'; import {imageLineBasedfootprintActionCreator} from './task/LSSTFootprintTask.js'; -import {REINIT_APP} from '../core/AppDataCntlr.js'; - -export const DRAWLAYER_PREFIX = 'DrawLayerCntlr'; - -export const SUBGROUP= 'subgroup'; - -/** {Enum} can be 'GROUP', 'SUBGROUP', 'SINGLE' */ -export const GroupingScope= new Enum(['STANDARD', 'SUBGROUP', 'SINGLE']); - - +import { + ANY_REPLOT, ATTACH_LAYER_TO_PLOT, CHANGE_CENTER_OF_PROJECTION, CHANGE_DRAWING_DEF, CHANGE_HIPS, CHANGE_VISIBILITY, + CREATE_DRAWING_LAYER, DELETE_PLOT_VIEW, DESTROY_DRAWING_LAYER, DETACH_LAYER_FROM_PLOT, DRAWING_LAYER_KEY, + DRAWLAYER_PREFIX, DT_END, ELT_END, ELT_START, FOOTPRINT_CREATE, FOOTPRINT_END, FOOTPRINT_MOVE, FOOTPRINT_START, + FORCE_DRAW_LAYER_UPDATE, IMAGELINEBASEDFP_CREATE, MARKER_CREATE, MARKER_END, MARKER_MOVE, MARKER_START, + MODIFY_CUSTOM_FIELD, REGION_ADD_ENTRY, REGION_CREATE_LAYER, REGION_DELETE_LAYER, REGION_REMOVE_ENTRY, + SELECT_AREA_END, UPDATE_DRAWING_LAYER +} from './VisConst'; +import {getDlAry} from './VisStoreRoots'; -const CREATE_DRAWING_LAYER= `${DRAWLAYER_PREFIX}.createDrawLayer`; -const UPDATE_DRAWING_LAYER= `${DRAWLAYER_PREFIX}.updateDrawLayer`; -const DESTROY_DRAWING_LAYER= `${DRAWLAYER_PREFIX}.destroyDrawLayer`; -const CHANGE_VISIBILITY= `${DRAWLAYER_PREFIX}.changeVisibility`; -const CHANGE_DRAWING_DEF= `${DRAWLAYER_PREFIX}.changeDrawingDef`; -export const ATTACH_LAYER_TO_PLOT= `${DRAWLAYER_PREFIX}.attachLayerToPlot`; const PRE_ATTACH_LAYER_TO_PLOT= `${DRAWLAYER_PREFIX}.attachLayerToPlot`; -const DETACH_LAYER_FROM_PLOT= `${DRAWLAYER_PREFIX}.detachLayerFromPlot`; -const MODIFY_CUSTOM_FIELD= `${DRAWLAYER_PREFIX}.modifyCustomField`; -const FORCE_DRAW_LAYER_UPDATE= `${DRAWLAYER_PREFIX}.forceDrawLayerUpdate`; - -// _- select -const SELECT_AREA_START= `${DRAWLAYER_PREFIX}.SelectArea.selectAreaStart`; -const SELECT_AREA_MOVE= `${DRAWLAYER_PREFIX}.SelectArea.selectAreaMove`; -const SELECT_AREA_END= `${DRAWLAYER_PREFIX}.SelectArea.selectAreaEnd`; -const SELECT_MOUSE_LOC= `${DRAWLAYER_PREFIX}.SelectArea.selectMouseLoc`; - -const SELECT_POINT= `${DRAWLAYER_PREFIX}.SelectPoint.selectPoint`; -const EXTRACT_POINT= `${DRAWLAYER_PREFIX}.ExtractPoints.extractPoint`; - - -// _- Distance tool -const DT_START= `${DRAWLAYER_PREFIX}.DistanceTool.distanceToolStart`; -const DT_MOVE= `${DRAWLAYER_PREFIX}.DistanceTool.distanceToolMove`; -const DT_END= `${DRAWLAYER_PREFIX}.DistanceTool.distanceToolEnd`; - -// _- Distance tool -const ELT_START= `${DRAWLAYER_PREFIX}.ExtractLineTool.distanceToolStart`; -const ELT_MOVE= `${DRAWLAYER_PREFIX}.ExtractLineTool.distanceToolMove`; -const ELT_END= `${DRAWLAYER_PREFIX}.ExtractLineTool.distanceToolEnd`; - -// region -const REGION_CREATE_LAYER = `${DRAWLAYER_PREFIX}.RegionPlot.createLayer`; -const REGION_DELETE_LAYER = `${DRAWLAYER_PREFIX}.RegionPlot.deleteLayer`; -const REGION_ADD_ENTRY = `${DRAWLAYER_PREFIX}.RegionPlot.addRegion`; -const REGION_REMOVE_ENTRY = `${DRAWLAYER_PREFIX}.RegionPlot.removeRegion`; -const REGION_SELECT = `${DRAWLAYER_PREFIX}.RegionPlot.selectRegion`; - -// marker and footprint -const MARKER_START = `${DRAWLAYER_PREFIX}.MarkerTool.markerStart`; -const MARKER_MOVE = `${DRAWLAYER_PREFIX}.MarkerTool.markerMove`; -const MARKER_END = `${DRAWLAYER_PREFIX}.MarkerTool.markerEnd`; -const MARKER_CREATE= `${DRAWLAYER_PREFIX}.MarkerTool.markerCreate`; -const FOOTPRINT_CREATE = `${DRAWLAYER_PREFIX}.FootprintTool.footprintCreate`; -const FOOTPRINT_START = `${DRAWLAYER_PREFIX}.FootprintTool.footprintStart`; -const FOOTPRINT_END = `${DRAWLAYER_PREFIX}.FootprintTool.footprintEnd`; -const FOOTPRINT_MOVE = `${DRAWLAYER_PREFIX}.FootprintTool.footprintMove`; - -const IMAGELINEBASEDFP_CREATE = `${DRAWLAYER_PREFIX}.ImageLineBasedFP.imagelineBasedFPCreate`; - -export const DRAWING_LAYER_KEY= 'drawLayers'; -export function dlRoot() { return flux.getState()[DRAWING_LAYER_KEY]; } - -export const RegionSelectStyle = ['UprightBox', 'DottedOverlay', 'SolidOverlay', - 'DottedReplace', 'SolidReplace']; -export const defaultRegionSelectColor = '#DAA520'; // golden -export const defaultRegionSelectStyle = RegionSelectStyle[0]; -export const RegionSelColor = 'selectColor'; -export const RegionSelStyle = 'selectStyle'; - - -export function getRegionSelectStyle(style = defaultRegionSelectStyle) { - const idx = RegionSelectStyle.findIndex((val) => { - return val.toLowerCase() === style.toLowerCase(); - }); - - return (idx < 0) ? defaultRegionSelectStyle : RegionSelectStyle[idx]; -} - -/** - * Return, from the store, the master array of all the drawing layers on all the plots - * @returns {DrawLayer[]} - * @memberof firefly.action - * @function getDlAry - */ -export function getDlAry() { return flux.getState()[DRAWING_LAYER_KEY].drawLayerAry; } - - -/** - * Return the draw layer store - * @returns {DrawLayerRoot} - * @memberof firefly.action - * @function getDlRoot - */ -export function getDlRoot() { return flux.getState()[DRAWING_LAYER_KEY]; } - - - export function getDrawLayerCntlrDef(drawLayerFactory) { @@ -151,8 +48,7 @@ export function getDrawLayerCntlrDef(drawLayerFactory) { dispatchAddActionWatcher({ actions:[CHANGE_VISIBILITY, CHANGE_DRAWING_DEF, ATTACH_LAYER_TO_PLOT, DETACH_LAYER_FROM_PLOT, FORCE_DRAW_LAYER_UPDATE, MODIFY_CUSTOM_FIELD, - ImagePlotCntlr.ANY_REPLOT, ImagePlotCntlr.CHANGE_HIPS, - ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION + ANY_REPLOT, CHANGE_HIPS, CHANGE_CENTER_OF_PROJECTION ], callback: asyncDrawDataWatcher, params: {drawLayerFactory} @@ -192,247 +88,10 @@ export function getDrawLayerCntlrDef(drawLayerFactory) { export default { getDrawLayerCntlrDef, - CHANGE_VISIBILITY, - ATTACH_LAYER_TO_PLOT, DETACH_LAYER_FROM_PLOT,CHANGE_DRAWING_DEF, - CREATE_DRAWING_LAYER,DESTROY_DRAWING_LAYER, MODIFY_CUSTOM_FIELD, - SELECT_AREA_START, SELECT_AREA_MOVE, SELECT_AREA_END, SELECT_MOUSE_LOC, - SELECT_POINT, EXTRACT_POINT, - FORCE_DRAW_LAYER_UPDATE, - DT_START, DT_MOVE, DT_END, - ELT_START, ELT_MOVE, ELT_END, - REGION_CREATE_LAYER, REGION_DELETE_LAYER, REGION_ADD_ENTRY, REGION_REMOVE_ENTRY, - REGION_SELECT, - MARKER_START, MARKER_MOVE, MARKER_END, MARKER_CREATE, - FOOTPRINT_CREATE, FOOTPRINT_START, FOOTPRINT_END, FOOTPRINT_MOVE, - IMAGELINEBASEDFP_CREATE, - dispatchCreateDrawLayer, - dispatchCreateImageLineBasedFootprintLayer }; -export function deleteAllDrawLayers() { - (getDlAry() || []) - .filter((l) => l.drawLayerId) - .forEach((id) => dispatchDestroyDrawLayer(id)); -} - - -/** - * @summary create drawing layer - * @param {string} drawLayerTypeId - id of drawing layer - * @param {Object} params - * @public - * @memberof firefly.action - * @function dispatchCreateDrawLayer - */ -export function dispatchCreateDrawLayer(drawLayerTypeId, params={}) { - const drawLayer= flux.createDrawLayer(drawLayerTypeId,params); - flux.process({type: CREATE_DRAWING_LAYER, payload: {drawLayer}} ); - - const plotIdAry= dlRoot().preAttachedTypes[drawLayerTypeId]; - if (plotIdAry) { - dispatchAttachLayerToPlot(drawLayerTypeId,plotIdAry); - } - return drawLayer; -} - - -/** - * @summary change the visibility of one more drawing layers on a set of WebPlots. - * This function can match the drawing layers using drawLayerId, drawLayerTypeId and further - * match using the title of the draw layer. it can match hhe plots by plotId, then all the plots in the group, and then - * can limit the plots in the group using subgroupId - * @param {Object} p - * @param {string|string[]} p.id - make the drawLayerId or drawLayerTypeId, this may be an array - * @param {boolean} p.visible - * @param {string} p.plotId - the plotId to change the visibility on, if used group is defined then visibility will be - * change for all the plotIds in the PlotGroup - * @param {boolean} [p.useGroup] - If true, get all the plotViews in the group of the plotId, if false use only the one - * @param {string} [p.subGroupId] - if defined the list of PlotViews affected will be filtered by the subGroupId. In other words - * it will only change the visibility on PlotView that have a matching subGroupId. - * @param {boolean} [p.matchTitle] - matches any draw layers that have the same title as the one specified by the id - * @public - * @memberof firefly.action - * @function dispatchChangeVisibility - */ -export function dispatchChangeVisibility({id,visible, plotId, useGroup= true, subGroupId, matchTitle= false}) { - let plotIdAry= useGroup ? getPlotViewIdListInOverlayGroup(visRoot(), plotId) : [plotId]; - if (subGroupId) { - const vr= visRoot(); - plotIdAry= plotIdAry.filter( (plotId) => { - const pv= getPlotViewById(vr,plotId); - return (pv && subGroupId===pv.drawingSubGroupId); - }); - } - if (plotIdAry.length) { - getDrawLayerIdAry(dlRoot(),id, matchTitle) - .forEach( (drawLayerId) => { - flux.process({type: CHANGE_VISIBILITY, payload: {drawLayerId, visible, plotIdAry} }); - }); - } -} - - -/** - * @summary change the drawing definition of the drawing layer - * @param {string|string[]} id make the drawLayerId or drawLayerTypeId, this may be an array - * @param drawingDef - * @param plotId - * @param {boolean} [matchTitle] - matches any draw layers that have the same title as the one specified by the id - * @public - * @memberof firefly.action - * @function dispatchChangeDrawingDef - */ -export function dispatchChangeDrawingDef(id,drawingDef, plotId, matchTitle= false) { - const plotIdAry= getPlotViewIdListInOverlayGroup(visRoot(), plotId); - - getDrawLayerIdAry(dlRoot(),id, matchTitle) - .forEach( (drawLayerId) => { - flux.process({type: CHANGE_DRAWING_DEF, payload: {drawLayerId, drawingDef, plotIdAry}}); - }); -} - - -/** - * @summary create custom changes to the drawing layer - * @param {string|string[]} id make the drawLayerId or drawLayerTypeId, this may be an array - * @param {Object} changes any object of changes - * @param {string} [plotId] a plotId - * @public - * @memberof firefly.action - * @function dispatchModifyCustomField - */ -export function dispatchModifyCustomField(id,changes, plotId) { - - const plotIdAry= getPlotViewIdListInOverlayGroup(visRoot(), plotId); - - getDrawLayerIdAry(dlRoot(),id) - .forEach( (drawLayerId) => { - flux.process({type: MODIFY_CUSTOM_FIELD, payload: {drawLayerId, changes, plotIdAry}}); - }); -} - -/** - * - * @param {DrawLayer|Object} drawLayer - */ -export function dispatchUpdateDrawLayer(drawLayer) { - flux.process({type: UPDATE_DRAWING_LAYER, payload: {drawLayer}}); -} - -/** - * @summary force to update the drawing layer - * @param id - * @param plotId - * @public - * @memberof firefly.action - * @function dispatchForceDrawLayerUpdate - */ -export function dispatchForceDrawLayerUpdate(id,plotId) { - - const plotIdAry= getPlotViewIdListInOverlayGroup(visRoot(), plotId); - - getDrawLayerIdAry(dlRoot(),id) - .forEach( (drawLayerId) => { - flux.process({type: FORCE_DRAW_LAYER_UPDATE, payload: {drawLayerId, plotIdAry}}); - }); -} - - - -/** - * @summary destroy the drawing layer - * @param {string} id make the drawLayerId or drawLayerTypeId - * @public - * @memberof firefly.action - * @function dispatchDestroyDrawLayer - */ -export function dispatchDestroyDrawLayer(id) { - const drawLayerId= getDrawLayerId(dlRoot(),id); - if (drawLayerId) { - flux.process({type: DESTROY_DRAWING_LAYER, payload: {drawLayerId} }); - } -} - -/** - * @summary attach drawing layer to plot - * @param {string|string[]} id make the drawLayerId or drawLayerTypeId, this may be an array - * @param {string|string[]} plotId to attach this may by a string or an array of strings - * @param {boolean} attachAllPlot - * @param {boolean|string} visible - Can have three values: true: layer is attach visible, false: attach not-visible, - * value (string) 'inherit' layer is visible - * @param {boolean} plotTypeMustMatch - * @memberof firefly.action - * @public - * @function dispatchAttachLayerToPlot - */ -export function dispatchAttachLayerToPlot(id,plotId, attachAllPlot=false, visible= true, plotTypeMustMatch=false) { - - let plotIdAry; - let layerVisible; - - if (visible==='inherit') { - layerVisible= getDrawLayerIdAry(dlRoot(),id, true).some( (drawLayerId) => - getDrawLayerById(dlRoot(),drawLayerId).visiblePlotIdAry.length); - } - else { - layerVisible= toBoolean(visible); - } - - if (Array.isArray(plotId)) { - plotIdAry= plotId; - } - else { - plotIdAry = attachAllPlot ? getAllPlotViewIdByOverlayLock(visRoot(), plotId, false, plotTypeMustMatch) : [plotId]; - } - - getDrawLayerIdAry(dlRoot(),id) - .forEach( (drawLayerId) => { - flux.process({type: ATTACH_LAYER_TO_PLOT, payload: {drawLayerId, plotIdAry, visible:layerVisible} }); - }); -} - - -/** - * @summary Detach drawing layer from the plot - * @param {string|string[]} id make the drawLayerId or drawLayerTypeId, this may be an array - * @param {string|string[]} plotId to attach this may by a string or an array of string - * @param detachAllPlot - * @param destroyWhenAllDetached if all plots are detached then destroy this plot - * @public - * @memberof firefly.action - * @function dispatchDetachLayerFromPlot - */ -export function dispatchDetachLayerFromPlot(id,plotId, detachAllPlot=false, destroyWhenAllDetached=false) { - let plotIdAry; - - if (Array.isArray(plotId)) { - plotIdAry= plotId; - } - else { - plotIdAry= detachAllPlot ? getAllPlotViewIdByOverlayLock(visRoot(), plotId) : [plotId]; - } - - getDrawLayerIdAry(dlRoot(),id) - .forEach( (drawLayerId) => { - flux.process({type: DETACH_LAYER_FROM_PLOT, payload: {drawLayerId,plotIdAry, destroyWhenAllDetached} }); - }); - -} - -/** - * check and create selectMode with valid property and value. - * @param selectMode - * @returns {{selectStyle, selectColor, lineWidth}} - */ -function validateSelectMode(selectMode) { - const {selectStyle = defaultRegionSelectStyle, selectColor = defaultRegionSelectColor, lineWidth = 0 } = selectMode; - const regSelectStyle = getRegionSelectStyle(selectStyle); - - return {selectStyle:regSelectStyle , selectColor, lineWidth}; -} - /** * @global * @public @@ -446,107 +105,6 @@ function validateSelectMode(selectMode) { * is the same as that of the selected region */ -/** - * @summary Create drawing layer based on region file or region description - * @param {string} drawLayerId - id of the drawing layer to be created, required - * @param {string} layerTitle - if it is empty, it will be created internally - * @param {string} fileOnServer - region file name on server - * @param {string[]|string} regionAry - array or string of region description - * @param {string[]|string} plotId - array or string of plot id. If plotId is empty, all plots of the active group are applied - * @param {RegionSelectMode} selectMode - rendering features for the selected region - * @param {Function} dispatcher - * @public - * @function dispatchCreateRegionLayer - * @memberof firefly.action - */ -export function dispatchCreateRegionLayer(drawLayerId, layerTitle, fileOnServer='', regionAry=[], plotId='', - selectMode = {}, - dispatcher = flux.process) { - - dispatcher({type: REGION_CREATE_LAYER, payload: {drawLayerId, fileOnServer, plotId, layerTitle, regionAry, - selectMode: validateSelectMode(selectMode)}}); -} - -/** - * @summary Delete the region drawing layer - * @param {string} drawLayerId - id of the drawing layer to be deleted, required - * @param {string[]|string} plotId - array or string of plot id. If plotId is empty, all plots of the active group are applied - * @param {Function} dispatcher - * @public - * @function dispatchDeleteRegionLayer - * @memberof firefly.action - */ -export function dispatchDeleteRegionLayer(drawLayerId, plotId, dispatcher = flux.process) { - dispatcher({type: REGION_DELETE_LAYER, payload: {drawLayerId, plotId}}); -} - - -/** - * @summary Add regions to drawing layer - * @param {string} drawLayerId - id of the drawing layer where the region(s) are added to - * if the layer doesn't exist, a new drawing layer is created by either using the specified drawLayerId or - * creating a new id based on the setting of 'layerTitle' in case drawLayerId is undefined - * @param {string[]|string} regionChanges - array or string of region description - * @param {string[]|string} plotId - array or string of plot id. If plotId is empty, all plots of the active group are applied - * @param {string} layerTitle - will replace the original title if the drawing layer exists and layerTitle is non-empty - * @param {RegionSelectMode} selectMode - rendering features for the selected region - * @param {Function} dispatcher - * @public - * @function dispatchAddRegionEntry - * @memberof firefly.action - */ -export function dispatchAddRegionEntry(drawLayerId, regionChanges, plotId=[], layerTitle='', - selectMode = {}, - dispatcher = flux.process) { - - dispatcher({type: REGION_ADD_ENTRY, payload: {drawLayerId, regionChanges, plotId, layerTitle, - selectMode: validateSelectMode(selectMode)}}); -} - -/** - * @summary remove region(s) from the drawing layer - * @param {string} drawLayerId - id of the drawing layer where the region(s) are removed from, required - * @param {string[]|string} regionChanges - array or string of region description - * @param {Function} dispatcher - * @public - * @function dispatchRemoveRegionEntry - * @memberof firefly.action - */ -export function dispatchRemoveRegionEntry(drawLayerId, regionChanges, dispatcher = flux.process) { - dispatcher({type: REGION_REMOVE_ENTRY, payload: {drawLayerId, regionChanges}}); -} - - -/** - * @summary select region from a drawing layer containing regions - * @param {string} drawLayerId - id of drawing layer where the region is selected from, required - * @param {string[]|string|Object} selectedRegion - array or string of region description or region object (drawObj) - * currently only single region is allowed to be selected if the array contains the description of multiple regions. - * If 'null' or empty array is passed, the function works as de-select the region. - * @param {Function} dispatcher - * @public - * @function dispatchSelectRegion - * @memberof firefly.action - * @see {@link firefly.util.image.getSelectedRegion} to get the string describing the selected region - */ -export function dispatchSelectRegion(drawLayerId, selectedRegion, dispatcher = flux.process) { - dispatcher({type: REGION_SELECT, payload: {drawLayerId, selectedRegion}}); -} - -/** - * @summary create drawing layer with marker - * @param {string} markerId - id of the drawing layer - * @param {string} layerTitle - title of the drawing layer - * @param {string[]|string} plotId - array or string of plot id. If plotId is empty, all plots of the active group are applied - * @param {bool} attachPlotGroup - attach all plots of the same plot group - * @param dispatcher - * @public - * @function dispatchCreateMarkerLayer - * @memberof firefly.action - */ -export function dispatchCreateMarkerLayer(markerId, layerTitle, plotId = [], attachPlotGroup=true, dispatcher = flux.process) { - dispatcher({type: MARKER_CREATE, payload: {plotId, markerId, layerTitle, attachPlotGroup}}); -} /** * Footprint Info. The data object containing footprint info. @@ -560,71 +118,6 @@ export function dispatchCreateMarkerLayer(markerId, layerTitle, plotId = [], att * @public */ -/** - * @summary create drawing layer with footprint - * @param {string} footprintId - id of the drawing layer - * @param {string} layerTitle - title of the drawing layer - * @param {footprintInfo} footprintData footprint information for footprint layer, - * relocateBy: 'origin' means relocating footprint origin to the target location - * 'center' means relocating footprint center to the target location - * @param {string[]|string} plotId - array or string of plot id. If plotId is empty, all plots of the active group are applied - * @param {bool} attachPlotGroup - attach all plots of the same plot group - * @param dispatcher - * @public - * @function dispatchCreateFootprintLayer - * @memberof firefly.action - */ -export function dispatchCreateFootprintLayer(footprintId, layerTitle, - {footprint=null, instrument=null, relocateBy='origin', fromFile=null, fromRegionAry=null}, - plotId = [], attachPlotGroup=true, dispatcher = flux.process) { - dispatcher({type: FOOTPRINT_CREATE, payload: {plotId, footprintId, layerTitle, footprint, instrument, relocateBy, attachPlotGroup, fromFile, fromRegionAry}}); - -} - -export function dispatchCreateImageLineBasedFootprintLayer(drawLayerId, title, fpData, plotId = [], - footprintFile, footprintImageFile, tbl_index, - attachPlotGroup=true, dispatcher = flux.process) { - dispatcher({ - type: IMAGELINEBASEDFP_CREATE, - payload: {plotId, drawLayerId, title, footprintData: fpData, footprintFile, footprintImageFile, tbl_index, attachPlotGroup} - }); -} - - -function getDrawLayerId(dlRoot,id) { - let drawLayer= dlRoot.drawLayerAry.find( (dl) => id===dl.drawLayerId); - if (!drawLayer) { - drawLayer= dlRoot.drawLayerAry.find( (dl) => id===dl.drawLayerTypeId); - } - return drawLayer ? drawLayer.drawLayerId : null; -} - -/** - * - * @param dlRoot - * @param id - drawLayerId or drawLayerTypeId or displayGroupId - * @param matchTitles - * @return {Array.} the list of drawLayerIds - */ -function getDrawLayerIdAry(dlRoot,id, matchTitles= false) { - const idAry= Array.isArray(id) ? id: [id]; - const dlAry= dlRoot.drawLayerAry - .filter( (dl) => idAry - .filter( (id) => new Set([dl.drawLayerId,dl.drawLayerTypeId,dl.displayGroupId]).has(id)) - .length>0); - - let retDlAry= dlAry; - if (matchTitles) { //look for any other DrawLayers with titles that match the already found list of layers - const matchTitleAry= - uniqBy(flatten(dlAry - .map( (dl) => dlRoot.drawLayerAry - .filter( (nextDl) => dl.title===nextDl.title && nextDl!==dl) )), 'drawLayerId'); - retDlAry= [...dlAry, ...matchTitleAry]; - } - - return retDlAry.map( (dl) => dl.drawLayerId); -} - //============================================= //============================================= @@ -730,12 +223,12 @@ function makeReducer(factory) { case PRE_ATTACH_LAYER_TO_PLOT: retState = preattachLayerToPlot(state,action); break; - case ImagePlotCntlr.DELETE_PLOT_VIEW: + case DELETE_PLOT_VIEW: retState = deletePlotView(state, action, dlReducer); break; - case ImagePlotCntlr.CHANGE_HIPS: - case ImagePlotCntlr.ANY_REPLOT: - case ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION: + case CHANGE_HIPS: + case ANY_REPLOT: + case CHANGE_CENTER_OF_PROJECTION: retState = determineAndCallLayerReducer(state, action, dlReducer, true); break; default: @@ -839,20 +332,17 @@ function preattachLayerToPlot(state,action) { const {drawLayerTypeId,plotIdAry}= action.payload; const currentAry= state.preAttachedTypes[drawLayerTypeId] || []; - const preAttachedTypes= clone( state.preAttachedTypes, {[drawLayerTypeId]: union(currentAry,plotIdAry)}); - return clone(state, {preAttachedTypes}); + const preAttachedTypes= {...state.preAttachedTypes, [drawLayerTypeId]: union(currentAry,plotIdAry)}; + return {...state, preAttachedTypes}; } function deletePlotView(state,action, dlReducer) { const {plotId} = action.payload; - const drawLayerAry= state.drawLayerAry .map( (dl) => dlReducer(dl, {type:DETACH_LAYER_FROM_PLOT, payload:{plotIdAry:[plotId]}})) .filter( (dl) => !(dl.destroyWhenAllDetached && isEmpty(dl.plotIdAry))); - - - return clone(state, {drawLayerAry}); + return {...state, drawLayerAry}; } /** @@ -874,9 +364,7 @@ const initState= function() { allowedActions: [ CREATE_DRAWING_LAYER, DESTROY_DRAWING_LAYER, CHANGE_VISIBILITY, ATTACH_LAYER_TO_PLOT, DETACH_LAYER_FROM_PLOT, MODIFY_CUSTOM_FIELD, CHANGE_DRAWING_DEF,FORCE_DRAW_LAYER_UPDATE, - ImagePlotCntlr.ANY_REPLOT, ImagePlotCntlr.DELETE_PLOT_VIEW, - ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION, - ImagePlotCntlr.CHANGE_HIPS, UPDATE_DRAWING_LAYER + ANY_REPLOT, DELETE_PLOT_VIEW, CHANGE_CENTER_OF_PROJECTION, CHANGE_HIPS, UPDATE_DRAWING_LAYER ], drawLayerAry : [], preAttachedTypes : {} // {futureDrawLayerTypeId : [string] } diff --git a/src/firefly/js/visualize/DrawLayerDispatch.js b/src/firefly/js/visualize/DrawLayerDispatch.js new file mode 100644 index 0000000000..f7f3799a8d --- /dev/null +++ b/src/firefly/js/visualize/DrawLayerDispatch.js @@ -0,0 +1,428 @@ +import {flatten, uniqBy} from 'lodash'; +import {flux} from '../core/ReduxFlux'; +import {dlRoot, visRoot} from './VisStoreRoots'; +import {toBoolean} from '../util/WebUtil'; +import { + getAllPlotViewIdByOverlayLock, getDrawLayerById, getPlotViewById, getPlotViewIdListInOverlayGroup +} from './PlotViewUtil'; +import { + ATTACH_LAYER_TO_PLOT, CHANGE_DRAWING_DEF, CHANGE_VISIBILITY, CREATE_DRAWING_LAYER, defaultRegionSelectColor, + defaultRegionSelectStyle, RegionSelectStyle, DESTROY_DRAWING_LAYER, UPDATE_DRAWING_LAYER, + DETACH_LAYER_FROM_PLOT, FOOTPRINT_CREATE, FORCE_DRAW_LAYER_UPDATE, IMAGELINEBASEDFP_CREATE, MARKER_CREATE, + MODIFY_CUSTOM_FIELD, REGION_ADD_ENTRY, REGION_CREATE_LAYER, REGION_DELETE_LAYER, REGION_REMOVE_ENTRY, REGION_SELECT, +} from './VisConst'; + +/** + * @summary create drawing layer + * @param {string} drawLayerTypeId - id of drawing layer + * @param {Object} params + * @public + * @memberof firefly.action + * @function dispatchCreateDrawLayer + */ +export function dispatchCreateDrawLayer(drawLayerTypeId, params = {}) { + const drawLayer = flux.createDrawLayer(drawLayerTypeId, params); + flux.process({type: CREATE_DRAWING_LAYER, payload: {drawLayer}}); + + const plotIdAry = dlRoot().preAttachedTypes[drawLayerTypeId]; + if (plotIdAry) { + dispatchAttachLayerToPlot(drawLayerTypeId, plotIdAry); + } + return drawLayer; +} + +/** + * @summary change the visibility of one more drawing layers on a set of WebPlots. + * This function can match the drawing layers using drawLayerId, drawLayerTypeId and further + * match using the title of the draw layer. it can match hhe plots by plotId, then all the plots in the group, and then + * can limit the plots in the group using subgroupId + * @param {Object} p + * @param {string|string[]} p.id - make the drawLayerId or drawLayerTypeId, this may be an array + * @param {boolean} p.visible + * @param {string} p.plotId - the plotId to change the visibility on, if used group is defined then visibility will be + * change for all the plotIds in the PlotGroup + * @param {boolean} [p.useGroup] - If true, get all the plotViews in the group of the plotId, if false use only the one + * @param {string} [p.subGroupId] - if defined the list of PlotViews affected will be filtered by the subGroupId. In other words + * it will only change the visibility on PlotView that have a matching subGroupId. + * @param {boolean} [p.matchTitle] - matches any draw layers that have the same title as the one specified by the id + * @public + * @memberof firefly.action + * @function dispatchChangeVisibility + */ +export function dispatchChangeVisibility({id, visible, plotId, useGroup = true, subGroupId, matchTitle = false}) { + let plotIdAry = useGroup ? getPlotViewIdListInOverlayGroup(visRoot(), plotId) : [plotId]; + if (subGroupId) { + const vr = visRoot(); + plotIdAry = plotIdAry.filter((plotId) => { + const pv = getPlotViewById(vr, plotId); + return (pv && subGroupId === pv.drawingSubGroupId); + }); + } + if (plotIdAry.length) { + getDrawLayerIdAry(dlRoot(), id, matchTitle) + .forEach((drawLayerId) => { + flux.process({type: CHANGE_VISIBILITY, payload: {drawLayerId, visible, plotIdAry}}); + }); + } +} + +/** + * @summary change the drawing definition of the drawing layer + * @param {string|string[]} id make the drawLayerId or drawLayerTypeId, this may be an array + * @param drawingDef + * @param plotId + * @param {boolean} [matchTitle] - matches any draw layers that have the same title as the one specified by the id + * @public + * @memberof firefly.action + * @function dispatchChangeDrawingDef + */ +export function dispatchChangeDrawingDef(id, drawingDef, plotId, matchTitle = false) { + const plotIdAry = getPlotViewIdListInOverlayGroup(visRoot(), plotId); + + getDrawLayerIdAry(dlRoot(), id, matchTitle) + .forEach((drawLayerId) => { + flux.process({type: CHANGE_DRAWING_DEF, payload: {drawLayerId, drawingDef, plotIdAry}}); + }); +} + +/** + * @summary create custom changes to the drawing layer + * @param {string|string[]} id make the drawLayerId or drawLayerTypeId, this may be an array + * @param {Object} changes any object of changes + * @param {string} [plotId] a plotId + * @public + * @memberof firefly.action + * @function dispatchModifyCustomField + */ +export function dispatchModifyCustomField(id, changes, plotId) { + + const plotIdAry = getPlotViewIdListInOverlayGroup(visRoot(), plotId); + + getDrawLayerIdAry(dlRoot(), id) + .forEach((drawLayerId) => { + flux.process({type: MODIFY_CUSTOM_FIELD, payload: {drawLayerId, changes, plotIdAry}}); + }); +} + +/** + * + * @param {DrawLayer|Object} drawLayer + */ +export function dispatchUpdateDrawLayer(drawLayer) { + flux.process({type: UPDATE_DRAWING_LAYER, payload: {drawLayer}}); +} + +/** + * @summary force to update the drawing layer + * @param id + * @param plotId + * @public + * @memberof firefly.action + * @function dispatchForceDrawLayerUpdate + */ +export function dispatchForceDrawLayerUpdate(id, plotId) { + + const plotIdAry = getPlotViewIdListInOverlayGroup(visRoot(), plotId); + + getDrawLayerIdAry(dlRoot(), id) + .forEach((drawLayerId) => { + flux.process({type: FORCE_DRAW_LAYER_UPDATE, payload: {drawLayerId, plotIdAry}}); + }); +} + +/** + * @summary destroy the drawing layer + * @param {string} id make the drawLayerId or drawLayerTypeId + * @public + * @memberof firefly.action + * @function dispatchDestroyDrawLayer + */ +export function dispatchDestroyDrawLayer(id) { + const drawLayerId = getDrawLayerId(dlRoot(), id); + if (drawLayerId) { + flux.process({type: DESTROY_DRAWING_LAYER, payload: {drawLayerId}}); + } +} + +/** + * @summary attach drawing layer to plot + * @param {string|string[]} id make the drawLayerId or drawLayerTypeId, this may be an array + * @param {string|string[]} plotId to attach this may by a string or an array of strings + * @param {boolean} attachAllPlot + * @param {boolean|string} visible - Can have three values: true: layer is attach visible, false: attach not-visible, + * value (string) 'inherit' layer is visible + * @param {boolean} plotTypeMustMatch + * @memberof firefly.action + * @public + * @function dispatchAttachLayerToPlot + */ +export function dispatchAttachLayerToPlot(id, plotId, attachAllPlot = false, visible = true, plotTypeMustMatch = false) { + + let plotIdAry; + let layerVisible; + + if (visible === 'inherit') { + layerVisible = getDrawLayerIdAry(dlRoot(), id, true).some((drawLayerId) => + getDrawLayerById(dlRoot(), drawLayerId).visiblePlotIdAry.length); + } else { + layerVisible = toBoolean(visible); + } + + if (Array.isArray(plotId)) { + plotIdAry = plotId; + } else { + plotIdAry = attachAllPlot ? getAllPlotViewIdByOverlayLock(visRoot(), plotId, false, plotTypeMustMatch) : [plotId]; + } + + getDrawLayerIdAry(dlRoot(), id) + .forEach((drawLayerId) => { + flux.process({type: ATTACH_LAYER_TO_PLOT, payload: {drawLayerId, plotIdAry, visible: layerVisible}}); + }); +} + +/** + * @summary Detach drawing layer from the plot + * @param {string|string[]} id make the drawLayerId or drawLayerTypeId, this may be an array + * @param {string|string[]} plotId to attach this may by a string or an array of string + * @param detachAllPlot + * @param destroyWhenAllDetached if all plots are detached then destroy this plot + * @public + * @memberof firefly.action + * @function dispatchDetachLayerFromPlot + */ +export function dispatchDetachLayerFromPlot(id, plotId, detachAllPlot = false, destroyWhenAllDetached = false) { + let plotIdAry; + + if (Array.isArray(plotId)) { + plotIdAry = plotId; + } else { + plotIdAry = detachAllPlot ? getAllPlotViewIdByOverlayLock(visRoot(), plotId) : [plotId]; + } + + getDrawLayerIdAry(dlRoot(), id) + .forEach((drawLayerId) => { + flux.process({type: DETACH_LAYER_FROM_PLOT, payload: {drawLayerId, plotIdAry, destroyWhenAllDetached}}); + }); + +} + +function getRegionSelectStyle(style = defaultRegionSelectStyle) { + const idx = RegionSelectStyle.findIndex((val) => { + return val.toLowerCase() === style.toLowerCase(); + }); + + return (idx < 0) ? defaultRegionSelectStyle : RegionSelectStyle[idx]; +} + + +/** + * @summary Create drawing layer based on region file or region description + * @param {string} drawLayerId - id of the drawing layer to be created, required + * @param {string} layerTitle - if it is empty, it will be created internally + * @param {string} fileOnServer - region file name on server + * @param {string[]|string} regionAry - array or string of region description + * @param {string[]|string} plotId - array or string of plot id. If plotId is empty, all plots of the active group are applied + * @param {RegionSelectMode} selectMode - rendering features for the selected region + * @param {Function} dispatcher + * @public + * @function dispatchCreateRegionLayer + * @memberof firefly.action + */ +export function dispatchCreateRegionLayer(drawLayerId, layerTitle, fileOnServer = '', regionAry = [], plotId = '', + selectMode = {}, + dispatcher = flux.process) { + + dispatcher({ + type: REGION_CREATE_LAYER, payload: { + drawLayerId, fileOnServer, plotId, layerTitle, regionAry, + selectMode: validateSelectMode(selectMode) + } + }); +} + +/** + * @summary Delete the region drawing layer + * @param {string} drawLayerId - id of the drawing layer to be deleted, required + * @param {string[]|string} plotId - array or string of plot id. If plotId is empty, all plots of the active group are applied + * @param {Function} dispatcher + * @public + * @function dispatchDeleteRegionLayer + * @memberof firefly.action + */ +export function dispatchDeleteRegionLayer(drawLayerId, plotId, dispatcher = flux.process) { + dispatcher({type: REGION_DELETE_LAYER, payload: {drawLayerId, plotId}}); +} + +/** + * @summary Add regions to drawing layer + * @param {string} drawLayerId - id of the drawing layer where the region(s) are added to + * if the layer doesn't exist, a new drawing layer is created by either using the specified drawLayerId or + * creating a new id based on the setting of 'layerTitle' in case drawLayerId is undefined + * @param {string[]|string} regionChanges - array or string of region description + * @param {string[]|string} plotId - array or string of plot id. If plotId is empty, all plots of the active group are applied + * @param {string} layerTitle - will replace the original title if the drawing layer exists and layerTitle is non-empty + * @param {RegionSelectMode} selectMode - rendering features for the selected region + * @param {Function} dispatcher + * @public + * @function dispatchAddRegionEntry + * @memberof firefly.action + */ +export function dispatchAddRegionEntry(drawLayerId, regionChanges, plotId = [], layerTitle = '', + selectMode = {}, + dispatcher = flux.process) { + + dispatcher({ + type: REGION_ADD_ENTRY, payload: { + drawLayerId, regionChanges, plotId, layerTitle, + selectMode: validateSelectMode(selectMode) + } + }); +} + +/** + * @summary remove region(s) from the drawing layer + * @param {string} drawLayerId - id of the drawing layer where the region(s) are removed from, required + * @param {string[]|string} regionChanges - array or string of region description + * @param {Function} dispatcher + * @public + * @function dispatchRemoveRegionEntry + * @memberof firefly.action + */ +export function dispatchRemoveRegionEntry(drawLayerId, regionChanges, dispatcher = flux.process) { + dispatcher({type: REGION_REMOVE_ENTRY, payload: {drawLayerId, regionChanges}}); +} + +/** + * @summary select region from a drawing layer containing regions + * @param {string} drawLayerId - id of drawing layer where the region is selected from, required + * @param {string[]|string|Object} selectedRegion - array or string of region description or region object (drawObj) + * currently only single region is allowed to be selected if the array contains the description of multiple regions. + * If 'null' or empty array is passed, the function works as de-select the region. + * @param {Function} dispatcher + * @public + * @function dispatchSelectRegion + * @memberof firefly.action + * @see {@link firefly.util.image.getSelectedRegion} to get the string describing the selected region + */ +export function dispatchSelectRegion(drawLayerId, selectedRegion, dispatcher = flux.process) { + dispatcher({type: REGION_SELECT, payload: {drawLayerId, selectedRegion}}); +} + +/** + * @summary create drawing layer with marker + * @param {string} markerId - id of the drawing layer + * @param {string} layerTitle - title of the drawing layer + * @param {string[]|string} plotId - array or string of plot id. If plotId is empty, all plots of the active group are applied + * @param {bool} attachPlotGroup - attach all plots of the same plot group + * @param dispatcher + * @public + * @function dispatchCreateMarkerLayer + * @memberof firefly.action + */ +export function dispatchCreateMarkerLayer(markerId, layerTitle, plotId = [], attachPlotGroup = true, dispatcher = flux.process) { + dispatcher({type: MARKER_CREATE, payload: {plotId, markerId, layerTitle, attachPlotGroup}}); +} + +/** + * @summary create drawing layer with footprint + * @param {string} footprintId - id of the drawing layer + * @param {string} layerTitle - title of the drawing layer + * @param {footprintInfo} footprintData footprint information for footprint layer, + * relocateBy: 'origin' means relocating footprint origin to the target location + * 'center' means relocating footprint center to the target location + * @param {string[]|string} plotId - array or string of plot id. If plotId is empty, all plots of the active group are applied + * @param {bool} attachPlotGroup - attach all plots of the same plot group + * @param dispatcher + * @public + * @function dispatchCreateFootprintLayer + * @memberof firefly.action + */ +export function dispatchCreateFootprintLayer(footprintId, layerTitle, + { + footprint = null, + instrument = null, + relocateBy = 'origin', + fromFile = null, + fromRegionAry = null + }, + plotId = [], attachPlotGroup = true, dispatcher = flux.process) { + dispatcher({ + type: FOOTPRINT_CREATE, + payload: { + plotId, + footprintId, + layerTitle, + footprint, + instrument, + relocateBy, + attachPlotGroup, + fromFile, + fromRegionAry + } + }); + +} + +export function dispatchCreateImageLineBasedFootprintLayer(drawLayerId, title, fpData, plotId = [], + footprintFile, footprintImageFile, tbl_index, + attachPlotGroup = true, dispatcher = flux.process) { + dispatcher({ + type: IMAGELINEBASEDFP_CREATE, + payload: { + plotId, + drawLayerId, + title, + footprintData: fpData, + footprintFile, + footprintImageFile, + tbl_index, + attachPlotGroup + } + }); +} + +function getDrawLayerId(dlRoot, id) { + let drawLayer = dlRoot.drawLayerAry.find((dl) => id === dl.drawLayerId); + if (!drawLayer) { + drawLayer = dlRoot.drawLayerAry.find((dl) => id === dl.drawLayerTypeId); + } + return drawLayer ? drawLayer.drawLayerId : null; +} + +/** + * + * @param dlRoot + * @param id - drawLayerId or drawLayerTypeId or displayGroupId + * @param matchTitles + * @return {Array.} the list of drawLayerIds + */ +function getDrawLayerIdAry(dlRoot, id, matchTitles = false) { + const idAry = Array.isArray(id) ? id : [id]; + const dlAry = dlRoot.drawLayerAry + .filter((dl) => idAry + .filter((id) => new Set([dl.drawLayerId, dl.drawLayerTypeId, dl.displayGroupId]).has(id)) + .length > 0); + + let retDlAry = dlAry; + if (matchTitles) { //look for any other DrawLayers with titles that match the already found list of layers + const matchTitleAry = + uniqBy(flatten(dlAry + .map((dl) => dlRoot.drawLayerAry + .filter((nextDl) => dl.title === nextDl.title && nextDl !== dl))), 'drawLayerId'); + retDlAry = [...dlAry, ...matchTitleAry]; + } + + return retDlAry.map((dl) => dl.drawLayerId); +} + +/** + * check and create selectMode with valid property and value. + * @param selectMode + * @returns {{selectStyle, selectColor, lineWidth}} + */ +function validateSelectMode(selectMode) { + const {selectStyle = defaultRegionSelectStyle, selectColor = defaultRegionSelectColor, lineWidth = 0} = selectMode; + const regSelectStyle = getRegionSelectStyle(selectStyle); + + return {selectStyle: regSelectStyle, selectColor, lineWidth}; +} diff --git a/src/firefly/js/visualize/HiPSMocUtil.js b/src/firefly/js/visualize/HiPSMocUtil.js index 508f9ad168..128f50bbf1 100644 --- a/src/firefly/js/visualize/HiPSMocUtil.js +++ b/src/firefly/js/visualize/HiPSMocUtil.js @@ -1,11 +1,12 @@ import {get, set, isEmpty, flatten, isArray} from 'lodash'; +import {dispatchCreateDrawLayer} from './DrawLayerDispatch'; import {getDrawLayersByType} from './PlotViewUtil.js'; -import {getDlAry, dispatchCreateDrawLayer} from './DrawLayerCntlr.js'; import HiPSMOC from '../drawingLayers/HiPSMOC.js'; import {getHealpixCornerTool} from './HiPSUtil.js'; import {getAppOptions} from '../core/AppDataCntlr.js'; import {getBooleanMetaEntry, getTblById} from '../tables/TableUtil'; import {MetaConst} from 'firefly/data/MetaConst.js'; +import {getDlAry} from './VisStoreRoots'; const HEADER_KEY_COL = 1; const HEADER_VAL_COL = 2; diff --git a/src/firefly/js/visualize/ImViewFilterDisplay.js b/src/firefly/js/visualize/ImViewFilterDisplay.js index 8cc2770103..7b741a3147 100644 --- a/src/firefly/js/visualize/ImViewFilterDisplay.js +++ b/src/firefly/js/visualize/ImViewFilterDisplay.js @@ -5,9 +5,10 @@ import {dispatchAddActionWatcher} from '../core/MasterSaga.js'; import {SelectInfo} from '../tables/SelectInfo.js'; import {dispatchTableAddLocal} from '../tables/TablesCntlr.js'; import {getTblById, getTblInfoById, processRequest} from '../tables/TableUtil.js'; -import ImagePlotCntlr, { dispatchChangeActivePlotView, dispatchDeletePlotView, visRoot } from './ImagePlotCntlr.js'; +import {dispatchChangeActivePlotView, dispatchDeletePlotView} from './ImagePlotDispatch'; +import {visRoot} from './VisStoreRoots'; +import {CHANGE_EXPANDED_MODE, DEFAULT_FITS_VIEWER_ID, EXPANDED_MODE_RESERVED, IMAGE} from './VisConst'; import { - DEFAULT_FITS_VIEWER_ID, EXPANDED_MODE_RESERVED, IMAGE, dispatchAddViewer, dispatchAddViewerItems, dispatchReplaceViewerItems, getMultiViewRoot, getViewerItemIds, } from './MultiViewCntlr.js'; import {PlotAttribute} from './PlotAttribute.js'; @@ -265,7 +266,7 @@ export function addExpandFilterSyncWatcher() { if (watcherAdded) return; watcherAdded= true; let lastState; - dispatchAddActionWatcher({ actions:[SET_LAYOUT_MODE, SET_LAYOUT,UPDATE_LAYOUT, ImagePlotCntlr.CHANGE_EXPANDED_MODE], + dispatchAddActionWatcher({ actions:[SET_LAYOUT_MODE, SET_LAYOUT,UPDATE_LAYOUT, CHANGE_EXPANDED_MODE], callback: () => { const expandedMode= getExpandedMode(); const imageExpanded= isImageExpanded(visRoot().expandedMode); diff --git a/src/firefly/js/visualize/ImagePlotCntlr.js b/src/firefly/js/visualize/ImagePlotCntlr.js index bb2df296e6..51a5dce15b 100644 --- a/src/firefly/js/visualize/ImagePlotCntlr.js +++ b/src/firefly/js/visualize/ImagePlotCntlr.js @@ -2,17 +2,11 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import {has, isArray} from 'lodash'; -import {REINIT_APP} from '../core/AppDataCntlr.js'; -import {flux} from '../core/ReduxFlux.js'; +import {has} from 'lodash'; + +import {REINIT_APP} from '../core/CoreConst'; import {convertToIdentityObj} from '../util/WebUtil.js'; import {changePrime} from './ChangePrime.js'; - -import {dispatchReplaceViewerItems} from './MultiViewCntlr.js'; -import {ExpandType, WcsMatchType, ActionScope, IMAGE, EXPANDED_MODE_RESERVED} from './VisConst.js'; -export {ExpandType, WcsMatchType, ActionScope} from './VisConst.js'; -import {getPlotGroupById} from './PlotGroup.js'; -import {getOnePvOrGroup, getPlotViewById, isActivePlotView, isImageExpanded, primePlot} from './PlotViewUtil.js'; import {reducer as plotAdminReducer} from './reducer/HandlePlotAdmin.js'; import {reducer as plotChangeReducer} from './reducer/HandlePlotChange.js'; import {reducer as plotCreationReducer} from './reducer/HandlePlotCreation.js'; @@ -23,135 +17,25 @@ import { autoPlayActionCreator, changePointSelectionActionCreator, deletePlotViewActionCreator, restoreDefaultsActionCreator } from './task/PlotAdminTask.js'; import { - flipActionCreator, processScrollActionCreator, recenterActionCreator, rotateActionCreator -} from './task/PlotChangeTask'; -import { + flipActionCreator, processScrollActionCreator, recenterActionCreator, rotateActionCreator, colorChangeActionCreator, cropActionCreator, requestLocalDataActionCreator, stretchChangeActionCreator -} from './task/PlotChangeTask.js'; -import {makeAbortHiPSAction} from './task/PlotHipsTask'; -import {makeChangeHiPSAction, makeImageOrHiPSAction, makePlotHiPSAction} from './task/PlotHipsTask.js'; +} from './task/PlotChangeTask'; +import {makeAbortHiPSAction, makeChangeHiPSAction, makeImageOrHiPSAction, makePlotHiPSAction} from './task/PlotHipsTask.js'; import {makePlotImageAction} from './task/PlotImageTask.js'; import {wcsMatchActionCreator} from './task/WcsMatchTask.js'; import {zoomActionCreator} from './task/ZoomTask.js'; -import {ZoomType} from './ZoomType.js'; - -import {UserZoomTypes} from './ZoomUtil.js'; - -// ExpandType, WcsMatchType, ActionScope are defined in VisConst.js and -// re-exported above (near the import) to keep this file free of circular deps. - -export const PLOTS_PREFIX= 'ImagePlotCntlr'; - -/** Action Type: plot of new image started */ -const PLOT_IMAGE_START= `${PLOTS_PREFIX}.PlotImageStart`; -/** Action Type: plot of new image failed */ -const PLOT_IMAGE_FAIL= `${PLOTS_PREFIX}.PlotImageFail`; -/** Action Type: plot of new image completed */ -const PLOT_IMAGE= `${PLOTS_PREFIX}.PlotImage`; -const PLOT_PROXY= `${PLOTS_PREFIX}.PlotProxy`; -const REMOVE_PROXY= `${PLOTS_PREFIX}.RemoveProxy`; - -/** Action Type: plot of new HiPS image */ -const PLOT_HIPS= `${PLOTS_PREFIX}.PlotHiPS`; -const ABORT_HIPS= `${PLOTS_PREFIX}.AbortHiPS`; -const CHANGE_HIPS= `${PLOTS_PREFIX}.ChangeHiPS`; -const PLOT_HIPS_OR_IMAGE= `${PLOTS_PREFIX}.plotHiPSOrImage`; -const PLOT_HIPS_FAIL= `${PLOTS_PREFIX}.PlotHiPSFail`; - - - -/** Action Type: A image replot occurred */ -const ANY_REPLOT= `${PLOTS_PREFIX}.Replot`; - -/** Action Type: start the zoom process. The image will appear zoomed by scaling, the server has not updated yet */ -const ZOOM_HIPS= `${PLOTS_PREFIX}.ZoomHiPS`; - -/** Action Type: The zoom from the server has complete */ -const ZOOM_IMAGE= `${PLOTS_PREFIX}.ZoomImage`; -const ZOOM_LOCKING= `${PLOTS_PREFIX}.ZoomEnableLocking`; - - -/** Action Type: image with new color table loaded */ -const COLOR_CHANGE= `${PLOTS_PREFIX}.ColorChange`; - -/** Action Type: image loaded with new stretch */ -const STRETCH_CHANGE= `${PLOTS_PREFIX}.StretchChange`; - -/** Action Type: image rotated */ -const ROTATE= `${PLOTS_PREFIX}.Rotate`; - -/** Action Type: image flipped */ -const FLIP= `${PLOTS_PREFIX}.Flip`; - - -const CROP_START= `${PLOTS_PREFIX}.CropStart`; -/** Action Type: image cropped */ -const CROP= `${PLOTS_PREFIX}.Crop`; -const CROP_FAIL= `${PLOTS_PREFIX}.CropFail`; - -const UPDATE_VIEW_SIZE= `${PLOTS_PREFIX}.UpdateViewSize`; -const PROCESS_SCROLL= `${PLOTS_PREFIX}.ProcessScroll`; -const CHANGE_CENTER_OF_PROJECTION= `${PLOTS_PREFIX}.changeCenterOfProjection`; -/** Action Type: Recenter in image on the active target */ -const RECENTER= `${PLOTS_PREFIX}.recenter`; -const MARK_OUT_OF_MEMORY= `${PLOTS_PREFIX}.makeOutOfMemory`; -/** Action Type: replot the image with the original plot parameters */ -const RESTORE_DEFAULTS= `${PLOTS_PREFIX}.restoreDefaults`; -const POSITION_LOCKING= `${PLOTS_PREFIX}.PositionLocking`; -const OVERLAY_COLOR_LOCKING= `${PLOTS_PREFIX}.OverlayColorLocking`; - -const CHANGE_POINT_SELECTION= `${PLOTS_PREFIX}.ChangePointSelection`; - -const CHANGE_ACTIVE_PLOT_VIEW= `${PLOTS_PREFIX}.ChangeActivePlotView`; -const CHANGE_SUBHIGHLIGHT_PLOT_VIEW= `${PLOTS_PREFIX}.ChangeSubHighlightPlotView`; -const CHANGE_PLOT_ATTRIBUTE= `${PLOTS_PREFIX}.ChangePlotAttribute`; - -/** Action Type: display mode to or from expanded */ -const CHANGE_EXPANDED_MODE= `${PLOTS_PREFIX}.changeExpandedMode`; -/** Action Type: turn on/off expanded auto-play */ -const EXPANDED_AUTO_PLAY= `${PLOTS_PREFIX}.expandedAutoPlay`; -/** Action Type: change the primary plot for a multi image fits display */ -const CHANGE_PRIME_PLOT= `${PLOTS_PREFIX}.changePrimePlot`; -const CHANGE_IMAGE_VISIBILITY= `${PLOTS_PREFIX}.changeImageVisibility`; - -const CHANGE_MOUSE_READOUT_MODE=`${PLOTS_PREFIX}.changeMouseReadoutMode`; -/** Action Type: delete a plotView */ -const DELETE_PLOT_VIEW=`${PLOTS_PREFIX}.deletePlotView`; - -const BYTE_DATA_REFRESH= `${PLOTS_PREFIX}.byteDataRefresh`; - -const PLOT_MASK_START= `${PLOTS_PREFIX}.plotMaskStart`; -/** Action Type: add a mask image*/ -const PLOT_MASK=`${PLOTS_PREFIX}.plotMask`; -const PLOT_MASK_LAZY_LOAD=`${PLOTS_PREFIX}.plotMaskLazyLoad`; -const PLOT_MASK_FAIL= `${PLOTS_PREFIX}.plotMaskFail`; -const DELETE_OVERLAY_PLOT=`${PLOTS_PREFIX}.deleteOverlayPlot`; -const OVERLAY_PLOT_CHANGE_ATTRIBUTES=`${PLOTS_PREFIX}.overlayPlotChangeAttributes`; -const CHANGE_HIPS_IMAGE_CONVERSION=`${PLOTS_PREFIX}.changeHipsImageConversion`; -const CHANGE_TABLE_AUTO_SCROLL=`${PLOTS_PREFIX}.changeTableAutoScroll`; -const USE_TABLE_AUTO_SCROLL=`${PLOTS_PREFIX}.useTableAutoScroll`; -const REQUEST_LOCAL_DATA=`${PLOTS_PREFIX}.requestLocalData`; - -const WCS_MATCH=`${PLOTS_PREFIX}.wcsMatch`; - -const PLOT_PROGRESS_UPDATE= `${PLOTS_PREFIX}.PlotProgressUpdate`; -const API_TOOLS_VIEW= `${PLOTS_PREFIX}.apiToolsView`; - -/** Action Type: enable/disable wcs matching*/ -export const IMAGE_PLOT_KEY= 'allPlots'; - -export const MOUSE_CLICK_REASON= 'mouseClickReason'; -export const OTHER_REASON= 'otherReason'; - -/** - * @returns {VisRoot} - * - * @public - * @function visRoot - * @memberof firefly.action - * */ -export function visRoot() { return flux.getState()[IMAGE_PLOT_KEY]; } - +import { + ABORT_HIPS, API_TOOLS_VIEW, BYTE_DATA_REFRESH, CHANGE_ACTIVE_PLOT_VIEW, CHANGE_CENTER_OF_PROJECTION, + CHANGE_EXPANDED_MODE, CHANGE_HIPS, CHANGE_HIPS_IMAGE_CONVERSION, CHANGE_IMAGE_VISIBILITY, CHANGE_MOUSE_READOUT_MODE, + CHANGE_PLOT_ATTRIBUTE, CHANGE_POINT_SELECTION, CHANGE_PRIME_PLOT, CHANGE_SUBHIGHLIGHT_PLOT_VIEW, + CHANGE_TABLE_AUTO_SCROLL, COLOR_CHANGE, CROP, CROP_FAIL, CROP_START, DELETE_OVERLAY_PLOT, DELETE_PLOT_VIEW, + EXPANDED_AUTO_PLAY, ExpandType, FLIP, IMAGE_PLOT_KEY, MARK_OUT_OF_MEMORY, + OVERLAY_COLOR_LOCKING, OVERLAY_PLOT_CHANGE_ATTRIBUTES, PLOT_HIPS, PLOT_HIPS_FAIL, PLOT_HIPS_OR_IMAGE, PLOT_IMAGE, + PLOT_IMAGE_FAIL, PLOT_IMAGE_START, PLOT_MASK, PLOT_MASK_FAIL, PLOT_MASK_LAZY_LOAD, PLOT_MASK_START, + PLOT_PROGRESS_UPDATE, PLOT_PROXY, PLOTS_PREFIX, POSITION_LOCKING, PROCESS_SCROLL, RECENTER, REMOVE_PROXY, + REQUEST_LOCAL_DATA, RESTORE_DEFAULTS, ROTATE, STRETCH_CHANGE, UPDATE_VIEW_SIZE, USE_TABLE_AUTO_SCROLL, WCS_MATCH, + ZOOM_HIPS, ZOOM_IMAGE, ZOOM_LOCKING, +} from './VisConst.js'; /** * @@ -285,745 +169,8 @@ function actionCreators() { } -export default { - reducers, actionCreators, - ANY_REPLOT, PLOT_IMAGE_START, PLOT_IMAGE_FAIL, PLOT_IMAGE, PLOT_HIPS, PLOT_HIPS_FAIL, CHANGE_HIPS,ABORT_HIPS, - ZOOM_HIPS, ZOOM_IMAGE, ZOOM_LOCKING, - CHANGE_CENTER_OF_PROJECTION, ROTATE, FLIP, CROP_START, CROP, CROP_FAIL, - COLOR_CHANGE, STRETCH_CHANGE, CHANGE_POINT_SELECTION, CHANGE_EXPANDED_MODE, - PLOT_PROGRESS_UPDATE, UPDATE_VIEW_SIZE, PROCESS_SCROLL, RECENTER, OVERLAY_COLOR_LOCKING, POSITION_LOCKING, - RESTORE_DEFAULTS, CHANGE_PLOT_ATTRIBUTE,EXPANDED_AUTO_PLAY, - DELETE_PLOT_VIEW, CHANGE_ACTIVE_PLOT_VIEW, CHANGE_PRIME_PLOT, CHANGE_IMAGE_VISIBILITY, - PLOT_MASK, PLOT_MASK_START, PLOT_MASK_FAIL, PLOT_MASK_LAZY_LOAD, DELETE_OVERLAY_PLOT, BYTE_DATA_REFRESH, - OVERLAY_PLOT_CHANGE_ATTRIBUTES, WCS_MATCH, API_TOOLS_VIEW, CHANGE_MOUSE_READOUT_MODE, - CHANGE_HIPS_IMAGE_CONVERSION, CHANGE_TABLE_AUTO_SCROLL, USE_TABLE_AUTO_SCROLL,REQUEST_LOCAL_DATA, - CHANGE_SUBHIGHLIGHT_PLOT_VIEW, MARK_OUT_OF_MEMORY, PLOT_PROXY, REMOVE_PROXY -}; - -const KEY_ROOT= 'progress-'; -let keyCnt= 0; -export function makeUniqueRequestKey(prefix= KEY_ROOT) { - const requestKey= `${prefix}-${keyCnt}-${Date.now()}`; - keyCnt++; - return requestKey; -} - - -//======================================== Dispatch Functions ============================= -//======================================== Dispatch Functions ============================= -//======================================== Dispatch Functions ============================= - -/** - * Tweek how the API image view works - * @param {boolean} apiToolsView - * - * @public - * @function dispatchApiToolsView - * @memberof firefly.action - */ -export function dispatchApiToolsView(apiToolsView) { - flux.process({ type: API_TOOLS_VIEW , payload: { apiToolsView}}); -} -/** - * - * @param {String} plotId - - * @param {String} message - the message if working or failure - * @param {boolean} done - true if completed, false if still working - * @param {String} requestKey - * @param {boolean} [callSuccess=true] - true if success, false otherwise, parameter ignored if done is false - */ -export function dispatchPlotProgressUpdate(plotId, message, done, requestKey, callSuccess= true ) { - flux.process({ type: PLOT_PROGRESS_UPDATE, payload: { plotId, done, message, requestKey, callSuccess }}); -} - -/** - * Notify that the size of the plot viewing area has changed - * - * @param {string} plotId - * @param {number} [width] this parameter should be the offsetWidth of the dom element - * @param {number} [height] this parameter should be the offsetHeight of the dom element - */ -export function dispatchUpdateViewSize(plotId,width,height) { - flux.process({type: UPDATE_VIEW_SIZE, payload: {plotId, width, height} }); -} - -/** - * change overlay/color lock for color change and overlays - * - * @param {string} plotId is required - * @param {boolean} overlayColorLock true to set group lockRelated on - */ -export function dispatchOverlayColorLocking(plotId,overlayColorLock) { - flux.process({ type: OVERLAY_COLOR_LOCKING, payload :{ plotId, overlayColorLock}}); -} - -/** - * change position lock for zoom and scrolling - * - * @param {string} plotId is required - * @param {boolean} positionLock true to set group lockRelated on - */ -export function dispatchPositionLocking(plotId,positionLock) { - flux.process({ type: POSITION_LOCKING, payload :{ plotId, positionLock }}); -} - -/** - * Change the primary plot for a multi image fits display - * Note - function parameter is a single object - * @param {Object} p - * @param {string} p.plotId - * @param {number} p.primeIdx - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - */ -export function dispatchChangePrimePlot({plotId, primeIdx, dispatcher= flux.process}) { - dispatcher({ type: CHANGE_PRIME_PLOT , payload: { plotId, primeIdx }}); -} - -/** - * set if the base image is visible on a PlotView or an OverlayPlotView - * @param {Object} p - * @param {string} p.plotId - * @param {string} [p.imageOverlayId] if defined change the visibility on the OverlayPlotView match this idea - * @param {boolean} p.visible - true if visible - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - */ -export function dispatchChangeImageVisibility({plotId, imageOverlayId, visible, dispatcher= flux.process}) { - dispatcher({ type: CHANGE_IMAGE_VISIBILITY, payload: { plotId, imageOverlayId, visible}}); -} - -/** - * Show image with new color table loaded - * Note - function parameter is a single object - * - * - * @param {Object} obj - * @param {string} obj.plotId - * @param {number} obj.cbarId must be in the range, 0 - 21, each number represents different color bar - * @param {number} obj.bias bias between 0 - 1, .5 is no bias - * @param {number} obj.contrast bias between 0 - 2, .1 is no contrast - * @param {Array.} obj.nanPixelColor a 3 cell array of [r,g,b] - * @param {boolean} obj.useRed use this band, only use with 3 color - * @param {boolean} obj.useGreen use this band, only use with 3 color - * @param {boolean} obj.useBlue use this band, only use with 3 color - * - * @param {string|ActionScope} [obj.actionScope] default to group - * @param {Function} [obj.dispatcher] only for special dispatching uses such as remote - * - * - * @public - * @function dispatchColorChange - * @memberof firefly.action - */ -export function dispatchColorChange({plotId, cbarId, bias, contrast, - useRed=true, useGreen=true, useBlue=true, nanPixelColor= [0,0,0], - actionScope=ActionScope.GROUP, dispatcher= flux.process} ) { - dispatcher({ type: COLOR_CHANGE, payload: { plotId, cbarId, bias, contrast, nanPixelColor, - useRed, useGreen, useBlue, actionScope }}); -} - -/** - * Change the image stretch - * Note - function parameter is a single object - * @param {Object} obj - object literal with dispatcher parameters - * @param {string} obj.plotId - * @param {Array.>} obj.stretchData - * @param {ActionScope} [obj.actionScope] default to group - * @param {Function} [obj.dispatcher] only for special dispatching uses such as remote - * - * @public - * @function dispatchStretchChange - * @memberof firefly.action - * - * @example - * // Example of stretch 2 - 98 percent, log stretch - * var rv= RangeValues.makeSimple(‘percent’, 2, 98, ‘log’); - * const stretchData= [{ band : 'NO_BAND', rv : rv, bandVisible: true }]; - * action.dispatchStretchChange({plotId:’myPlot’, stretchData:stretchData }); - * @example - * // Example of stretch -2 - 5 sigma, linear stretch - * var rv= RangeValues.makeSimple(’sigma’, -2, 5, 'linear’); - * const stretchData= [{ band : 'NO_BAND', rv : rv, bandVisible: true }]; - * action.dispatchStretchChange({plotId:’myPlot’, stretchData:stretchData }); - * - */ -export function dispatchStretchChange({plotId, stretchData, - actionScope=ActionScope.GROUP, dispatcher= flux.process} ) { - dispatcher({ type: STRETCH_CHANGE, payload: { plotId, stretchData, actionScope }}); -} - -/** - * Enable / Disable WCS Match - * @param {Object} p - * @param {string} p.plotId - * @param {WcsMatchType|string|boolean} p.matchType one of 'Standard', 'Off', or you may pass false - * @param {boolean} [p.lockMatch] - * @param {Function} [p.dispatcher] - */ -export function dispatchWcsMatch({plotId, matchType, lockMatch= true, dispatcher= flux.process} ) { - dispatcher({ type: WCS_MATCH, payload: { plotId, matchType, lockMatch}}); -} - - -/** - * Rotate image, do it client side - * - * Note - function parameter is a single object - * @param {Object} p - * @param {string} p.plotId - * @param {RotateType} p.rotateType enum RotateType - * @param {number} [p.angle] - rotation angle- rotation is always toward the east of north. That is east-left images will - * rotate counter-clockwise, while east-right image will rotate clockwise - * @param {string|ActionScope} [p.actionScope] enum ActionScope - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - * - * @public - * @function dispatchRotate - * @memberof firefly.action - */ -export function dispatchRotate({plotId, rotateType, angle=-1, - actionScope=ActionScope.GROUP, dispatcher= flux.process} ) { - dispatcher({ type: ROTATE, payload: { plotId, angle, rotateType, actionScope}}); -} - -/** - * @summary Flip - * Note - function parameter is a single object - * @param {Object} p - * @param {string} p.plotId - * @param {boolean} [p.isY] - * @param {boolean} [p.rematchAfterFlip] - * @param {string|ActionScope} [p.actionScope] enum ActionScope - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - * - * @public - * @function dispatchFlip - * @memberof firefly.action - */ -export function dispatchFlip({plotId, isY=true, rematchAfterFlip= true, - actionScope=ActionScope.GROUP, dispatcher= flux.process}) { - dispatcher({ type: FLIP, payload: { plotId, isY, rematchAfterFlip, actionScope}}); -} - -/** - * @summary Crop - * Note - function parameter is a single object - * @param {Object} p - * @param {string} p.plotId - * @param {Object} p.imagePt1 image point of corner 1 - * @param {Object} p.imagePt2 image point of corner 2 - * @param {boolean} p.cropMultiAll - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - * - * @public - * @function dispatchCrop - * @memberof firefly.action - */ -export function dispatchCrop({plotId, imagePt1, imagePt2, cropMultiAll, dispatcher= flux.process}) { - dispatcher({ type: CROP, payload: { plotId, imagePt1, imagePt2, cropMultiAll}}); -} - - -/** - * @summary Move the scroll point on this plotId and possible others if it is grouped. - * - * Note - function parameter is a single object - * @param {Object} p - * @param {string} p.plotId - * @param {Object} p.scrollPt a new point to scroll - * @param {Object} [p.disableBoundCheck] - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - */ -export function dispatchProcessScroll({plotId,scrollPt, disableBoundCheck=false, dispatcher= flux.process}) { - dispatcher({type: PROCESS_SCROLL, payload: {plotId, scrollPt,disableBoundCheck} }); -} - -/** - * - * @param {Object} p - * @param {string} p.plotId - * @param {WorldPt|undefined} [p.centerProjPt] new center, if undefined just keep the same center - * @param {boolean} [p.fullSky] if true AITOFF, false half sky, undefined then don't change - * @param {boolean} [p.doWcsImageMatching] - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - */ -export function dispatchChangeCenterOfProjection({plotId,centerProjPt, fullSky, doWcsImageMatching, dispatcher= flux.process}) { - dispatcher({type: CHANGE_CENTER_OF_PROJECTION, payload: {plotId, centerProjPt, doWcsImageMatching, fullSky} }); -} - -/** - * @summary recenter the images on the plot center or the ACTIVE_TARGET - * - * Note - function parameter is a single object - * @param {Object} p - * @param {string} p.plotId - * @param {Point} [p.centerPt] Point to center on - * @param {boolean} [p.centerOnImage] only used if centerPt is not defined. If true then the centering will be - * the center of the image. If false, then the center point will be the - * FIXED_TARGET attribute, if defined. Otherwise it will be the center of the image. - * @param {boolean} [p.updateFixedTarget] if true and centerPt is a worldPt, it will update the - * FIXED_TARGET attribute on the plot - * @param {boolean} [p.updateWcsPrimId] if true update the make plotId the prime for wcs matching, defaults to true - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - * - * @public - * @function dispatchRecenter - * @memberof firefly.action - */ -export function dispatchRecenter({plotId, centerPt= undefined, centerOnImage=false, - updateWcsPrimId=true, - updateFixedTarget= false, dispatcher= flux.process}) { - dispatcher({type: RECENTER, payload: {plotId, centerPt, centerOnImage, updateFixedTarget, updateWcsPrimId} }); -} - -export function dispatchMarkOutOfMemory({plotId, markOutOfMemory= true, dispatcher= flux.process}) { - dispatcher({type: MARK_OUT_OF_MEMORY, payload: {plotId, markOutOfMemory}}); -} -/** - * @summary replot the image with the original plot parameters - * - * Note - function parameter is a single object - * @param {Object} p this function takes a single parameter - * @param {string} p.plotId - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - * @function dispatchRestoreDefaults - */ -export function dispatchRestoreDefaults({plotId, dispatcher= flux.process}) { - dispatcher({type: RESTORE_DEFAULTS, payload: {plotId} }); -} - -/** - * @summary add placeholder for a plot. message is optional and any other parameters will the passed through to the - * react component - * @param {Object} p - * @param {string} p.plotId is required unless defined in the WebPlotRequest - * @param {string} [p.message] is required unless defined in the WebPlotRequest - * @param {string} p.viewerId - viewer that this plot should be put into - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - */ -export function dispatchPlotProxy({plotId,message,viewerId,dispatcher= flux.process, ...rest}) { - dispatcher({ type: PLOT_PROXY, payload: {plotId,message,viewerId, ...rest} }); -} - -export function dispatchRemoveProxy({plotId,dispatcher= flux.process}) { - dispatcher({ type: REMOVE_PROXY, payload: {plotId} }); -} - -/** - * @summary Plot an image. - * @description Note - function parameter is a single object - * @param {Object} p - * @param {string} [p.plotId] is required unless defined in the WebPlotRequest - * @param {WebPlotParams|WebPlotRequest|Array} p.wpRequest - plotting parameters, required or for 3 color pass an array of WebPlotParams or WebPlotRequest - * @param {boolean} [p.threeColor] is a three color request, if true the wpRequest should be an array - * @param {boolean} [p.useContextModifications=true] it true the request will be modified to use preferences, rotation, etc - * should only be false when it is doing a 'restore to defaults' type plot - * @param {Object} [p.attributes] meta data that is added the plot - * @param {HipsImageConversionSettings} [p.hipsImageConversion= undefined] if defined, use these parameter to - * convert between image and HiPS - * @param {Object} [p.pvOptions] parameter specific to the plotView, only read the first time per plot id - * @param {boolean} [p.setNewPlotAsActive= true] the new plot will be active - * @param {boolean} [p.holdWcsMatch= false] if wcs match is on, then modify the request to hold the wcs match - * @param {boolean} [p.enableRestore= true] if true the original request is saved for restore - * @param {string} [p.viewerId] - viewer that this plot should be put into, only optional if - * you have added the plot id manually to a viewer. - * otherwise, you need to specify the viewer. - * @param {string} [p.renderTreeId] - used only with multiple rendered tree, like slate in jupyter lab - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - * @public - * @function dispatchPlotImage - * @memberof firefly.action - */ -export function dispatchPlotImage({plotId,wpRequest, threeColor=isArray(wpRequest), - useContextModifications= true, - dispatcher= flux.process, - attributes={}, - pvOptions= {}, - hipsImageConversion= undefined, - setNewPlotAsActive= true, - holdWcsMatch= true, - enableRestore= true, - viewerId, - renderTreeId} ) { - - dispatcher({ type: PLOT_IMAGE, - payload: {plotId,wpRequest, threeColor, pvOptions, hipsImageConversion, enableRestore, - attributes, holdWcsMatch, setNewPlotAsActive, - useContextModifications,viewerId, renderTreeId}}); -} - -/** - * @summary Plot a group of images. - * Note - function parameter is a single object - * @param {Object} p this function takes a single parameter - * @param {WebPlotRequest[]} p.wpRequestAry - * @param {string} p.viewerId - * @param {PVCreateOptions} p.pvOptions PlotView init Options - * @param {Object} [p.attributes] meta data that is added the plot - * @param {boolean} [p.setNewPlotAsActive] the last completed plot will be active - * @param {boolean} [p.holdWcsMatch= true] if wcs match is on, then modify the request to hold the wcs match - * @param {boolean} [p.enableRestore= true] if true the original request is saved for restore - * @param {string} [p.renderTreeId] - used only with multiple rendered tree, like slate in jupyter lab - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - */ -export function dispatchPlotGroup({wpRequestAry, viewerId, pvOptions= {}, - attributes={}, setNewPlotAsActive= true, holdWcsMatch= true, renderTreeId, - enableRestore= true, - dispatcher= flux.process}) { - dispatcher( { type: PLOT_IMAGE, payload: { wpRequestAry, pvOptions, attributes, setNewPlotAsActive, - enableRestore, holdWcsMatch, viewerId, renderTreeId} }); -} - - -/** - * @summary Plot a HiPS display - * @description Note - function parameter is a single object - * @param {Object} p this function takes a single parameter - * @param {string} p.plotId - * @param {WebPlotParams|WebPlotRequest} p.wpRequest - * @param {HipsImageConversionSettings} [p.hipsImageConversion= undefined] if defined, use these parameter to - * @param {string} [p.viewerId] - * @param {PVCreateOptions} [p.pvOptions] PlotView init Options - * @param {Object} [p.attributes] meta data that is added the plot - * @param {boolean} [p.setNewPlotAsActive] the last completed plot will be active - * @param {boolean} [p.enableRestore= true] if true the original request is saved for restore - * @param {string} [p.renderTreeId] - used only with multiple rendered tree, like slate in jupyter lab - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - * - * @public - * @function dispatchPlotHiPS - * @memberof firefly.action - */ -export function dispatchPlotHiPS({plotId,wpRequest, viewerId, pvOptions= {}, attributes={}, - hipsImageConversion= undefined, - enableRestore= true, renderTreeId, - setNewPlotAsActive= true, dispatcher= flux.process }) { - dispatcher( { type: PLOT_HIPS, payload: {wpRequest, plotId, pvOptions, attributes, enableRestore, renderTreeId, - hipsImageConversion, setNewPlotAsActive, viewerId} }); -} - -export function dispatchAbortHiPS({plotId, dispatcher= flux.process }) { - dispatcher( { type: ABORT_HIPS, payload: {plotId} }); -} - - -/** - * @summary Plot a HiPS or a image depending on the FOV size - * @description Note - function parameter is a single object - * @param {Object} p this function takes a single parameter - * @param {string} p.plotId - * @param {WebPlotParams|WebPlotRequest} p.hipsRequest - * @param {WebPlotParams|WebPlotRequest} p.imageRequest - must be a ServiceType request. - * @param {WebPlotParams|WebPlotRequest} p.allSkyRequest - must be an allsky type request, this is deprecated, parameter ignored - * @param {boolean} [p.plotAllSkyFirst= false] - if there is an all sky set up then plot that first - * @param {number} [p.fovDegFallOver] - the size in degrees that the image will switch between hips and a image cutout - * @param {number} [p.fovMaxFitsSize] - the max size the fits image service can support - * @param {boolean} [p.autoConvertOnZoom] - convert between images and FITS on zoom - * @param {string} [p.viewerId] - * @param {string} [p.renderTreeId] - used only with multiple rendered tree, like slate in jupyter lab - * @param {PVCreateOptions} [p.pvOptions] PlotView init Options - * @param {Object} [p.attributes] meta data that is added the plot - * @param {boolean} [p.setNewPlotAsActive] the last completed plot will be active - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - * - * @public - * @function dispatchPlotImageOrHiPS - * @memberof firefly.action - */ -export function dispatchPlotImageOrHiPS({plotId,hipsRequest, imageRequest, allSkyRequest, viewerId, fovDegFallOver=.12, - fovMaxFitsSize= .12, autoConvertOnZoom= false, - pvOptions= {}, attributes={}, plotAllSkyFirst= false, - setNewPlotAsActive= true, renderTreeId, dispatcher= flux.process }) { - - dispatcher( { type: PLOT_HIPS_OR_IMAGE, - payload: {hipsRequest, imageRequest, allSkyRequest, plotId, fovDegFallOver, pvOptions, renderTreeId, - fovMaxFitsSize, autoConvertOnZoom, attributes, setNewPlotAsActive, viewerId, plotAllSkyFirst} }); -} - -/** - * - * @param {Object} p this function takes a single parameter - * @param {string} p.plotId - * @param {HipsImageConversionSettings} p.hipsImageConversionChanges changes to HipsImageConversionSettings, newOptions can contain any key in - * HipsImageConversionSettings - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - */ -export function dispatchChangeHipsImageConversion({plotId, hipsImageConversionChanges, - dispatcher= flux.process}) { - dispatcher( { type: CHANGE_HIPS_IMAGE_CONVERSION, payload: {plotId, hipsImageConversionChanges}}); -} - - - -/** - * - * @summary change the hips repository or some other attribute - * @param {Object} p this function takes a single parameter - * @param {string} p.plotId - * @param {string} [p.hipsUrlRoot] - * @param {CoordinateSys} [p.coordSys] - * @param {number} [p.cubeIdx] - * @param {WorldPt} [p.centerProjPt] - * @param {String} [p.blankColor] set the background color of the hips if is is a blank hips - * @param {boolean} [p.applyToGroup] apply to the whole group it is locked - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - */ -export function dispatchChangeHiPS({ plotId, hipsUrlRoot, coordSys, centerProjPt, cubeIdx, blankColor, - applyToGroup=true, dispatcher= flux.process }) { - dispatcher( { type: CHANGE_HIPS, payload: {plotId, hipsUrlRoot, coordSys, cubeIdx, applyToGroup, centerProjPt, blankColor} }); -} - - - - -/** - * @summary Add a mask - * @param {Object} p this function takes a single parameter - * @param {string} p.plotId - * @param {number} p.maskValue power of 2, e.g 4, 8, 32, 128, etc - * @param {number} p.maskNumber 2, e.g 4, 8, 32, 128, etc - * @param {string} p.imageOverlayId - * @param {number} p.hduNumber hdu number of fits - * @param {string} p.fileKey file on the server - * @param {string} p.color - color is optional, if not specified, one is chosen - * @param {string} p.title - * @param {string} p.description - a more detailed description of the layer - * @param {string} p.lazyLoad - * @param {string} p.uiCanAugmentTitle - * @param {string} [p.relatedDataId] pass a related data id if one exist - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - * - * @public - * @function dispatchPlotMask - * @memberof firefly.action - */ -export function dispatchPlotMask({plotId,imageOverlayId, maskValue, fileKey, - hduNumber, maskNumber=-1, color, title, - uiCanAugmentTitle, description, - relatedDataId, lazyLoad, dispatcher= flux.process}) { - - dispatcher( { type: PLOT_MASK, payload: { plotId,imageOverlayId, fileKey, maskValue, - uiCanAugmentTitle, hduNumber, maskNumber, description, - color, title, relatedDataId, lazyLoad } }); -} - -export function dispatchPlotMaskLazyLoad(payload ) { - flux.process( { type: PLOT_MASK_LAZY_LOAD, payload}); -} - -/** - * - * - * @param {Object} p this function takes a single parameter - * @param {string} p.plotId - * @param {string} [p.imageOverlayId] the id of the overlay optional if deleteAll is true - * @param {string} [p.deleteAll] delete all the overlay plot on the given plotId, defaults to false - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - */ -export function dispatchDeleteOverlayPlot({plotId,imageOverlayId, deleteAll= false, dispatcher= flux.process}) { - dispatcher( { type: DELETE_OVERLAY_PLOT, payload: { plotId,imageOverlayId, deleteAll} }); -} - - -/** - * - * @param {Object} p this function takes a single parameter - * @param {string} p.plotId - * @param {string} p.imageOverlayId - * @param {Object} p.attributes any attribute in OverlayPlotView - * @param {boolean} p.doReplot if false don't do a replot just change attributes - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - */ -export function dispatchOverlayPlotChangeAttributes({plotId,imageOverlayId, attributes, doReplot=false, dispatcher= flux.process}) { - dispatcher( { type: OVERLAY_PLOT_CHANGE_ATTRIBUTES, payload: { plotId,imageOverlayId, attributes, doReplot} }); -} - - -/** - * @summary Zoom a image - * Note - function parameter is a single object - * @param {Object} p this function takes a single parameter - * @param {string} p.plotId - * @param {string|UserZoomTypes} p.userZoomType (one of ['UP','DOWN', 'FIT', 'FILL', 'ONE', 'LEVEL', 'WCS_MATCH_PREV') - * @param {boolean} [p.maxCheck] - * @param {boolean} [p.zoomLockingEnabled] - * @param {number} [p.level] the level to zoom to, used only userZoomType 'LEVEL' - * @param {number} [p.upDownPercent] value between 0 and 1 - 1 is 100% of the next step up or down - * @param {string|ActionScope} [p.actionScope] default to group - * @param {DevicePt} [p.devicePt] - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - * - * @public - * @function dispatchZoom - * @memberof firefly.action - * - * @example - * // Example of zoom to level - * action.dispatchZoom({plotId:’myPlot’, userZoomType:’LEVEL’, level: .75 }); - * - * @example - * // Example of zoom up - * action.dispatchZoom({plotId:’myPlot’, userZoomType:’UP’ }}; - * @example - * // Example of zoom to fit - * action.dispatchZoom({plotId:’myPlot’, userZoomType:’FIT’ }}; - * @example - * // Example of zoom to level, if you are connected to a widget that is changing the level fast, zLevel is the variable with the zoom level - * action.dispatchZoom({plotId:’myPlot’, userZoomType:’LEVEL’, level: zLevel }}; - */ -export function dispatchZoom({plotId, userZoomType, maxCheck= true, upDownPercent=1, - zoomLockingEnabled=false, level, devicePt, - actionScope=ActionScope.GROUP, dispatcher= flux.process} ) { - dispatcher({ - type: ZOOM_IMAGE, - payload :{ plotId, userZoomType, actionScope, maxCheck, zoomLockingEnabled, level, devicePt, upDownPercent}}); -} - -/** - * @summary Delete a PlotView - * Note - function parameter is a single object - * @param {Object} p this function takes a single parameter - * @param {string} p.plotId - * @param {boolean} [p.holdWcsMatch= true] if wcs match is on, then modify the request to hold the wcs match - * @param {Function} [p.dispatcher] only for special dispatching uses such as remote - * @public - * @function dispatchDeletePlotView - * @memberof firefly.action - */ -export function dispatchDeletePlotView({plotId, holdWcsMatch= true, dispatcher= flux.process}) { - dispatcher({ type: DELETE_PLOT_VIEW, payload: {plotId, holdWcsMatch} }); -} - - -/** - * - * @param {string} plotId - * @param {boolean} zoomLockingEnabled - * @param {UserZoomTypes|string} zoomLockingType should be 'FIT' or 'FILL' - */ -export function dispatchZoomLocking(plotId,zoomLockingEnabled, zoomLockingType) { - flux.process({ type: ZOOM_LOCKING, payload :{ plotId, zoomLockingEnabled, zoomLockingType }}); -} - - -/** - * Set the plotId of the active plot view - * @param {string} plotId - * @param {string} reason - */ - -export function dispatchChangeActivePlotView(plotId,reason=OTHER_REASON) { - if (!isActivePlotView(visRoot(),plotId)) { - flux.process({ type: CHANGE_ACTIVE_PLOT_VIEW, payload: {plotId,reason} }); - } -} - -/** - * Set the plotId ot be subhighlight - * @param {Object} p this function takes a single parameter - * @param {Array.<{plotId:String, subHighlight:boolean}>} p.subHighlightAry subHighlight updates - */ -export function dispatchChangeSubHighPlotView({subHighlightAry}) { - flux.process({ type: CHANGE_SUBHIGHLIGHT_PLOT_VIEW, payload: {subHighlightAry} }); -} +export default { reducers, actionCreators}; -/** - * - * @param {Object} p this function takes a single parameter - * @param p.plotId - * @param p.overlayColorScope - * @param p.positionScope - * @param p.attKey - * @param p.attValue - * @param {Object} p.changes attribute changes, use if more than one - * @param p.toAllPlotsInPlotView if a multiImageFits apply to all the images - */ -export function dispatchAttributeChange({plotId,overlayColorScope=true,positionScope=false, - changes, attKey,attValue,toAllPlotsInPlotView=true}) { - flux.process({ - type: CHANGE_PLOT_ATTRIBUTE, - payload: {plotId,attKey,attValue,changes,overlayColorScope,positionScope, toAllPlotsInPlotView} - }); -} - -/** - * - * @param requester a string id of the requester - * @param enabled true will add the request to the list, false will remove, when all requests are removed - * Point selection will be turned off - */ -export function dispatchChangePointSelection(requester, enabled) { - flux.process({ type: CHANGE_POINT_SELECTION, payload: {requester,enabled} }); -} - -export function dispatchChangeTableAutoScroll(enabled) { - flux.process({ type: CHANGE_TABLE_AUTO_SCROLL, payload: {enabled} }); -} - -export function dispatchUseTableAutoScroll(useAutoScroll) { - flux.process({ type: USE_TABLE_AUTO_SCROLL, payload: {useAutoScroll} }); -} - -export function dispatchRequestLocalData({plotId, plotImageId, imageOverlayId, dataRequested=true}) { - flux.process({ type: REQUEST_LOCAL_DATA, payload: {plotId,plotImageId, dataRequested, imageOverlayId} }); -} - -/** - * - * @param {ExpandType|boolean} expandedMode the mode to change to, it true the expand and match the last one, - * if false colapse - * - */ -export function dispatchChangeExpandedMode(expandedMode) { //todo: this code should be in a action creator - - const vr= visRoot(); - - if (!isImageExpanded(vr.expandedMode) && isImageExpanded(expandedMode)) { // if going from collapsed to expanded - const plotId= vr.activePlotId; - const pv= getPlotViewById(vr,plotId); - if (pv) { - const group= getPlotGroupById(vr,pv.plotGroupId); - const plotIdAry= getOnePvOrGroup(vr.plotViewAry,plotId,group, true) - .filter((pv) => pv.plotViewCtx.canBeExpanded) - .map( (pv) => pv.plotId); - dispatchReplaceViewerItems(EXPANDED_MODE_RESERVED,plotIdAry, IMAGE ); - } - } - - - flux.process({ type: CHANGE_EXPANDED_MODE, payload: {expandedMode} }); - - - const enable= expandedMode!==ExpandType.COLLAPSE; - visRoot().plotViewAry.forEach( (pv) => { - const p= primePlot(pv); - const zlEnabled= enable && p && - p.plotState.getWebPlotRequest() && - p.plotState.getWebPlotRequest().getZoomType()!==ZoomType.LEVEL; - dispatchZoomLocking(pv.plotId,zlEnabled,pv.plotViewCtx.zoomLockingType); - }); - - if (!enable) { - visRoot().plotViewAry.forEach( (pv) => { - const level= pv.plotViewCtx.lastCollapsedZoomLevel; - if (level>0) { - dispatchZoom({ - plotId:pv.plotId, - userZoomType:UserZoomTypes.LEVEL, - level, maxCheck:false, - actionScope:ActionScope.SINGLE}); - } - }); - } -} - - -/** - * Turn Auto play on - * @param {boolean} autoPlayOn - */ -export function dispatchExpandedAutoPlay(autoPlayOn) { - flux.process({ type: EXPANDED_AUTO_PLAY, payload: {autoPlayOn} }); -} //======================================== Action Creators ============================= diff --git a/src/firefly/js/visualize/ImagePlotDispatch.js b/src/firefly/js/visualize/ImagePlotDispatch.js new file mode 100644 index 0000000000..4503e8a0a1 --- /dev/null +++ b/src/firefly/js/visualize/ImagePlotDispatch.js @@ -0,0 +1,739 @@ +import {isArray} from 'lodash'; +import {flux} from '../core/ReduxFlux'; +import {currentP, getOnePvOrGroup, getPlotViewById, isImageExpanded, primePlot} from './PlotViewUtil'; +import {getPlotGroupById} from './PlotGroup'; +import {visRoot} from './VisStoreRoots'; +import { + ABORT_HIPS, ActionScope, API_TOOLS_VIEW, CHANGE_ACTIVE_PLOT_VIEW, CHANGE_CENTER_OF_PROJECTION, CHANGE_EXPANDED_MODE, + CHANGE_HIPS, CHANGE_HIPS_IMAGE_CONVERSION, CHANGE_IMAGE_VISIBILITY, CHANGE_PLOT_ATTRIBUTE, CHANGE_POINT_SELECTION, + CHANGE_PRIME_PLOT, CHANGE_SUBHIGHLIGHT_PLOT_VIEW, CHANGE_TABLE_AUTO_SCROLL, COLOR_CHANGE, CROP, DELETE_OVERLAY_PLOT, + DELETE_PLOT_VIEW, EXPANDED_AUTO_PLAY, EXPANDED_MODE_RESERVED, ExpandType, FLIP, IMAGE, + MARK_OUT_OF_MEMORY, OTHER_REASON, OVERLAY_COLOR_LOCKING, OVERLAY_PLOT_CHANGE_ATTRIBUTES, + PLOT_HIPS, PLOT_HIPS_OR_IMAGE, PLOT_IMAGE, PLOT_MASK, PLOT_MASK_LAZY_LOAD, PLOT_PROGRESS_UPDATE, PLOT_PROXY, + POSITION_LOCKING, PROCESS_SCROLL, RECENTER, REMOVE_PROXY, REQUEST_LOCAL_DATA, RESTORE_DEFAULTS, ROTATE, + STRETCH_CHANGE, UPDATE_VIEW_SIZE, USE_TABLE_AUTO_SCROLL, UserZoomTypes, ZoomType, WCS_MATCH, ZOOM_IMAGE, + ZOOM_LOCKING, REPLACE_VIEWER_ITEMS, +} from './VisConst'; + + + +/** + * @summary Plot an image. + * @description Note - function parameter is a single object + * @param {Object} p + * @param {string} [p.plotId] is required unless defined in the WebPlotRequest + * @param {WebPlotParams|WebPlotRequest|Array} p.wpRequest - plotting parameters, required or for 3 color pass an array of WebPlotParams or WebPlotRequest + * @param {boolean} [p.threeColor] is a three color request, if true the wpRequest should be an array + * @param {boolean} [p.useContextModifications=true] it true the request will be modified to use preferences, rotation, etc + * should only be false when it is doing a 'restore to defaults' type plot + * @param {Object} [p.attributes] meta data that is added the plot + * @param {HipsImageConversionSettings} [p.hipsImageConversion= undefined] if defined, use these parameter to + * convert between image and HiPS + * @param {Object} [p.pvOptions] parameter specific to the plotView, only read the first time per plot id + * @param {boolean} [p.setNewPlotAsActive= true] the new plot will be active + * @param {boolean} [p.holdWcsMatch= false] if wcs match is on, then modify the request to hold the wcs match + * @param {boolean} [p.enableRestore= true] if true the original request is saved for restore + * @param {string} [p.viewerId] - viewer that this plot should be put into, only optional if + * you have added the plot id manually to a viewer. + * otherwise, you need to specify the viewer. + * @param {string} [p.renderTreeId] - used only with multiple rendered tree, like slate in jupyter lab + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + * @public + * @function dispatchPlotImage + * @memberof firefly.action + */ +export function dispatchPlotImage({plotId,wpRequest, threeColor=isArray(wpRequest), + useContextModifications= true, + dispatcher= flux.process, + attributes={}, + pvOptions= {}, + hipsImageConversion= undefined, + setNewPlotAsActive= true, + holdWcsMatch= true, + enableRestore= true, + viewerId, + renderTreeId} ) { + + dispatcher({ type: PLOT_IMAGE, + payload: {plotId,wpRequest, threeColor, pvOptions, hipsImageConversion, enableRestore, + attributes, holdWcsMatch, setNewPlotAsActive, + useContextModifications,viewerId, renderTreeId}}); +} + +/** + * @summary Plot a group of images. + * Note - function parameter is a single object + * @param {Object} p this function takes a single parameter + * @param {WebPlotRequest[]} p.wpRequestAry + * @param {string} p.viewerId + * @param {PVCreateOptions} p.pvOptions PlotView init Options + * @param {Object} [p.attributes] meta data that is added the plot + * @param {boolean} [p.setNewPlotAsActive] the last completed plot will be active + * @param {boolean} [p.holdWcsMatch= true] if wcs match is on, then modify the request to hold the wcs match + * @param {boolean} [p.enableRestore= true] if true the original request is saved for restore + * @param {string} [p.renderTreeId] - used only with multiple rendered tree, like slate in jupyter lab + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + */ +export function dispatchPlotGroup({wpRequestAry, viewerId, pvOptions= {}, + attributes={}, setNewPlotAsActive= true, holdWcsMatch= true, renderTreeId, + enableRestore= true, + dispatcher= flux.process}) { + dispatcher( { type: PLOT_IMAGE, payload: { wpRequestAry, pvOptions, attributes, setNewPlotAsActive, + enableRestore, holdWcsMatch, viewerId, renderTreeId} }); +} + +/** + * @summary Plot a HiPS display + * @description Note - function parameter is a single object + * @param {Object} p this function takes a single parameter + * @param {string} p.plotId + * @param {WebPlotParams|WebPlotRequest} p.wpRequest + * @param {HipsImageConversionSettings} [p.hipsImageConversion= undefined] if defined, use these parameter to + * @param {string} [p.viewerId] + * @param {PVCreateOptions} [p.pvOptions] PlotView init Options + * @param {Object} [p.attributes] meta data that is added the plot + * @param {boolean} [p.setNewPlotAsActive] the last completed plot will be active + * @param {boolean} [p.enableRestore= true] if true the original request is saved for restore + * @param {string} [p.renderTreeId] - used only with multiple rendered tree, like slate in jupyter lab + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + * + * @public + * @function dispatchPlotHiPS + * @memberof firefly.action + */ +export function dispatchPlotHiPS({plotId,wpRequest, viewerId, pvOptions= {}, attributes={}, + hipsImageConversion= undefined, + enableRestore= true, renderTreeId, + setNewPlotAsActive= true, dispatcher= flux.process }) { + dispatcher( { type: PLOT_HIPS, payload: {wpRequest, plotId, pvOptions, attributes, enableRestore, renderTreeId, + hipsImageConversion, setNewPlotAsActive, viewerId} }); +} + +export function dispatchAbortHiPS({plotId, dispatcher= flux.process }) { + dispatcher( { type: ABORT_HIPS, payload: {plotId} }); +} + +/** + * @summary Plot a HiPS or a image depending on the FOV size + * @description Note - function parameter is a single object + * @param {Object} p this function takes a single parameter + * @param {string} p.plotId + * @param {WebPlotParams|WebPlotRequest} p.hipsRequest + * @param {WebPlotParams|WebPlotRequest} p.imageRequest - must be a ServiceType request. + * @param {WebPlotParams|WebPlotRequest} p.allSkyRequest - must be an allsky type request, this is deprecated, parameter ignored + * @param {boolean} [p.plotAllSkyFirst= false] - if there is an all sky set up then plot that first + * @param {number} [p.fovDegFallOver] - the size in degrees that the image will switch between hips and a image cutout + * @param {number} [p.fovMaxFitsSize] - the max size the fits image service can support + * @param {boolean} [p.autoConvertOnZoom] - convert between images and FITS on zoom + * @param {string} [p.viewerId] + * @param {string} [p.renderTreeId] - used only with multiple rendered tree, like slate in jupyter lab + * @param {PVCreateOptions} [p.pvOptions] PlotView init Options + * @param {Object} [p.attributes] meta data that is added the plot + * @param {boolean} [p.setNewPlotAsActive] the last completed plot will be active + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + * + * @public + * @function dispatchPlotImageOrHiPS + * @memberof firefly.action + */ +export function dispatchPlotImageOrHiPS({plotId,hipsRequest, imageRequest, allSkyRequest, viewerId, fovDegFallOver=.12, + fovMaxFitsSize= .12, autoConvertOnZoom= false, + pvOptions= {}, attributes={}, plotAllSkyFirst= false, + setNewPlotAsActive= true, renderTreeId, dispatcher= flux.process }) { + + dispatcher( { type: PLOT_HIPS_OR_IMAGE, + payload: {hipsRequest, imageRequest, allSkyRequest, plotId, fovDegFallOver, pvOptions, renderTreeId, + fovMaxFitsSize, autoConvertOnZoom, attributes, setNewPlotAsActive, viewerId, plotAllSkyFirst} }); +} + +/** + * + * @param {Object} p this function takes a single parameter + * @param {string} p.plotId + * @param {HipsImageConversionSettings} p.hipsImageConversionChanges changes to HipsImageConversionSettings, newOptions can contain any key in + * HipsImageConversionSettings + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + */ +export function dispatchChangeHipsImageConversion({plotId, hipsImageConversionChanges, + dispatcher= flux.process}) { + dispatcher( { type: CHANGE_HIPS_IMAGE_CONVERSION, payload: {plotId, hipsImageConversionChanges}}); +} + +/** + * + * @summary change the hips repository or some other attribute + * @param {Object} p this function takes a single parameter + * @param {string} p.plotId + * @param {string} [p.hipsUrlRoot] + * @param {CoordinateSys} [p.coordSys] + * @param {number} [p.cubeIdx] + * @param {WorldPt} [p.centerProjPt] + * @param {String} [p.blankColor] set the background color of the hips if is is a blank hips + * @param {boolean} [p.applyToGroup] apply to the whole group it is locked + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + */ +export function dispatchChangeHiPS({ plotId, hipsUrlRoot, coordSys, centerProjPt, cubeIdx, blankColor, + applyToGroup=true, dispatcher= flux.process }) { + dispatcher( { type: CHANGE_HIPS, payload: {plotId, hipsUrlRoot, coordSys, cubeIdx, applyToGroup, centerProjPt, blankColor} }); +} + +/** + * @summary Add a mask + * @param {Object} p this function takes a single parameter + * @param {string} p.plotId + * @param {number} p.maskValue power of 2, e.g 4, 8, 32, 128, etc + * @param {number} p.maskNumber 2, e.g 4, 8, 32, 128, etc + * @param {string} p.imageOverlayId + * @param {number} p.hduNumber hdu number of fits + * @param {string} p.fileKey file on the server + * @param {string} p.color - color is optional, if not specified, one is chosen + * @param {string} p.title + * @param {string} p.description - a more detailed description of the layer + * @param {string} p.lazyLoad + * @param {string} p.uiCanAugmentTitle + * @param {string} [p.relatedDataId] pass a related data id if one exist + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + * + * @public + * @function dispatchPlotMask + * @memberof firefly.action + */ +export function dispatchPlotMask({plotId,imageOverlayId, maskValue, fileKey, + hduNumber, maskNumber=-1, color, title, + uiCanAugmentTitle, description, + relatedDataId, lazyLoad, dispatcher= flux.process}) { + + dispatcher( { type: PLOT_MASK, payload: { plotId,imageOverlayId, fileKey, maskValue, + uiCanAugmentTitle, hduNumber, maskNumber, description, + color, title, relatedDataId, lazyLoad } }); +} + +export function dispatchPlotMaskLazyLoad(payload ) { + flux.process( { type: PLOT_MASK_LAZY_LOAD, payload}); +} + +/** + * + * + * @param {Object} p this function takes a single parameter + * @param {string} p.plotId + * @param {string} [p.imageOverlayId] the id of the overlay optional if deleteAll is true + * @param {string} [p.deleteAll] delete all the overlay plot on the given plotId, defaults to false + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + */ +export function dispatchDeleteOverlayPlot({plotId,imageOverlayId, deleteAll= false, dispatcher= flux.process}) { + dispatcher( { type: DELETE_OVERLAY_PLOT, payload: { plotId,imageOverlayId, deleteAll} }); +} + +/** + * + * @param {Object} p this function takes a single parameter + * @param {string} p.plotId + * @param {string} p.imageOverlayId + * @param {Object} p.attributes any attribute in OverlayPlotView + * @param {boolean} p.doReplot if false don't do a replot just change attributes + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + */ +export function dispatchOverlayPlotChangeAttributes({plotId,imageOverlayId, attributes, doReplot=false, dispatcher= flux.process}) { + dispatcher( { type: OVERLAY_PLOT_CHANGE_ATTRIBUTES, payload: { plotId,imageOverlayId, attributes, doReplot} }); +} + +/** + * @summary Zoom a image + * Note - function parameter is a single object + * @param {Object} p this function takes a single parameter + * @param {string} p.plotId + * @param {string|UserZoomTypes} p.userZoomType (one of ['UP','DOWN', 'FIT', 'FILL', 'ONE', 'LEVEL', 'WCS_MATCH_PREV') + * @param {boolean} [p.maxCheck] + * @param {boolean} [p.zoomLockingEnabled] + * @param {number} [p.level] the level to zoom to, used only userZoomType 'LEVEL' + * @param {number} [p.upDownPercent] value between 0 and 1 - 1 is 100% of the next step up or down + * @param {string|ActionScope} [p.actionScope] default to group + * @param {DevicePt} [p.devicePt] + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + * + * @public + * @function dispatchZoom + * @memberof firefly.action + * + * @example + * // Example of zoom to level + * action.dispatchZoom({plotId:’myPlot’, userZoomType:’LEVEL’, level: .75 }); + * + * @example + * // Example of zoom up + * action.dispatchZoom({plotId:’myPlot’, userZoomType:’UP’ }}; + * @example + * // Example of zoom to fit + * action.dispatchZoom({plotId:’myPlot’, userZoomType:’FIT’ }}; + * @example + * // Example of zoom to level, if you are connected to a widget that is changing the level fast, zLevel is the variable with the zoom level + * action.dispatchZoom({plotId:’myPlot’, userZoomType:’LEVEL’, level: zLevel }}; + */ +export function dispatchZoom({plotId, userZoomType, maxCheck= true, upDownPercent=1, + zoomLockingEnabled=false, level, devicePt, + actionScope=ActionScope.GROUP, dispatcher= flux.process} ) { + dispatcher({ + type: ZOOM_IMAGE, + payload :{ plotId, userZoomType, actionScope, maxCheck, zoomLockingEnabled, level, devicePt, upDownPercent}}); +} + +/** + * @summary Delete a PlotView + * Note - function parameter is a single object + * @param {Object} p this function takes a single parameter + * @param {string} p.plotId + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + * @public + * @function dispatchDeletePlotView + * @memberof firefly.action + */ +export function dispatchDeletePlotView({plotId, dispatcher= flux.process}) { + dispatcher({ type: DELETE_PLOT_VIEW, payload: {plotId} }); +} + +/** + * + * @param {string} plotId + * @param {boolean} zoomLockingEnabled + * @param {UserZoomTypes|string} zoomLockingType should be 'FIT' or 'FILL' + */ +export function dispatchZoomLocking(plotId,zoomLockingEnabled, zoomLockingType) { + flux.process({ type: ZOOM_LOCKING, payload :{ plotId, zoomLockingEnabled, zoomLockingType }}); +} + +/** + * Set the plotId of the active plot view + * @param {string} plotId + * @param {string} reason + */ + +export function dispatchChangeActivePlotView(plotId,reason=OTHER_REASON) { + if (!currentP(plotId).active) { + flux.process({ type: CHANGE_ACTIVE_PLOT_VIEW, payload: {plotId,reason} }); + } +} + +/** + * Set the plotId ot be subhighlight + * @param {Object} p this function takes a single parameter + * @param {Array.<{plotId:String, subHighlight:boolean}>} p.subHighlightAry subHighlight updates + */ +export function dispatchChangeSubHighPlotView({subHighlightAry}) { + flux.process({ type: CHANGE_SUBHIGHLIGHT_PLOT_VIEW, payload: {subHighlightAry} }); +} + +/** + * + * @param {Object} p this function takes a single parameter + * @param p.plotId + * @param p.overlayColorScope + * @param p.positionScope + * @param p.attKey + * @param p.attValue + * @param {Object} p.changes attribute changes, use if more than one + * @param p.toAllPlotsInPlotView if a multiImageFits apply to all the images + */ +export function dispatchAttributeChange({plotId,overlayColorScope=true,positionScope=false, + changes, attKey,attValue,toAllPlotsInPlotView=true}) { + flux.process({ + type: CHANGE_PLOT_ATTRIBUTE, + payload: {plotId,attKey,attValue,changes,overlayColorScope,positionScope, toAllPlotsInPlotView} + }); +} + +/** + * + * @param requester a string id of the requester + * @param enabled true will add the request to the list, false will remove, when all requests are removed + * Point selection will be turned off + */ +export function dispatchChangePointSelection(requester, enabled) { + flux.process({ type: CHANGE_POINT_SELECTION, payload: {requester,enabled} }); +} + +export function dispatchChangeTableAutoScroll(enabled) { + flux.process({ type: CHANGE_TABLE_AUTO_SCROLL, payload: {enabled} }); +} + +export function dispatchUseTableAutoScroll(useAutoScroll) { + flux.process({ type: USE_TABLE_AUTO_SCROLL, payload: {useAutoScroll} }); +} + +export function dispatchRequestLocalData({plotId, plotImageId, imageOverlayId, dataRequested=true}) { + flux.process({ type: REQUEST_LOCAL_DATA, payload: {plotId,plotImageId, dataRequested, imageOverlayId} }); +} + +/** + * + * @param {ExpandType|boolean} expandedMode the mode to change to, it true the expand and match the last one, + * if false colapse + * + */ +export function dispatchChangeExpandedMode(expandedMode) { //todo: this code should be in a action creator + + const vr= visRoot(); + + if (!isImageExpanded(vr.expandedMode) && isImageExpanded(expandedMode)) { // if going from collapsed to expanded + const plotId= vr.activePlotId; + const pv= getPlotViewById(vr,plotId); + if (pv) { + const group= getPlotGroupById(vr,pv.plotGroupId); + const plotIdAry= getOnePvOrGroup(vr.plotViewAry,plotId,group, true) + .filter((pv) => pv.plotViewCtx.canBeExpanded) + .map( (pv) => pv.plotId); + flux.process({type: REPLACE_VIEWER_ITEMS , payload: {viewerId:EXPANDED_MODE_RESERVED, itemIdAry:plotIdAry, containerType:IMAGE} }); + } + } + + + flux.process({ type: CHANGE_EXPANDED_MODE, payload: {expandedMode} }); + + + const enable= expandedMode!==ExpandType.COLLAPSE; + visRoot().plotViewAry.forEach( (pv) => { + const p= primePlot(pv); + const zlEnabled= enable && p && + p.plotState.getWebPlotRequest() && + p.plotState.getWebPlotRequest().getZoomType()!==ZoomType.LEVEL; + dispatchZoomLocking(pv.plotId,zlEnabled,pv.plotViewCtx.zoomLockingType); + }); + + if (!enable) { + visRoot().plotViewAry.forEach( (pv) => { + const level= pv.plotViewCtx.lastCollapsedZoomLevel; + if (level>0) { + dispatchZoom({ + plotId:pv.plotId, + userZoomType:UserZoomTypes.LEVEL, + level, maxCheck:false, + actionScope:ActionScope.SINGLE}); + } + }); + } +} + +/** + * Turn Auto play on + * @param {boolean} autoPlayOn + */ +export function dispatchExpandedAutoPlay(autoPlayOn) { + flux.process({ type: EXPANDED_AUTO_PLAY, payload: {autoPlayOn} }); +} + +/** + * Enable / Disable WCS Match + * @param {Object} p + * @param {string} p.plotId + * @param {WcsMatchType|string|boolean} p.matchType one of 'Standard', 'Off', or you may pass false + * @param {boolean} [p.lockMatch] + * @param {Function} [p.dispatcher] + */ +export function dispatchWcsMatch({plotId, matchType, lockMatch = true, dispatcher = flux.process}) { + dispatcher({type: WCS_MATCH, payload: {plotId, matchType, lockMatch}}); +} + +export function dispatchRemoveProxy({plotId, dispatcher = flux.process}) { + dispatcher({type: REMOVE_PROXY, payload: {plotId}}); +} + +/** + * Change the image stretch + * Note - function parameter is a single object + * @param {Object} obj - object literal with dispatcher parameters + * @param {string} obj.plotId + * @param {Array.>} obj.stretchData + * @param {ActionScope} [obj.actionScope] default to group + * @param {Function} [obj.dispatcher] only for special dispatching uses such as remote + * + * @public + * @function dispatchStretchChange + * @memberof firefly.action + * + * @example + * // Example of stretch 2 - 98 percent, log stretch + * var rv= RangeValues.makeSimple(‘percent’, 2, 98, ‘log’); + * const stretchData= [{ band : 'NO_BAND', rv : rv, bandVisible: true }]; + * action.dispatchStretchChange({plotId:’myPlot’, stretchData:stretchData }); + * @example + * // Example of stretch -2 - 5 sigma, linear stretch + * var rv= RangeValues.makeSimple(’sigma’, -2, 5, 'linear’); + * const stretchData= [{ band : 'NO_BAND', rv : rv, bandVisible: true }]; + * action.dispatchStretchChange({plotId:’myPlot’, stretchData:stretchData }); + * + */ +export function dispatchStretchChange({ + plotId, stretchData, + actionScope = ActionScope.GROUP, dispatcher = flux.process + }) { + dispatcher({type: STRETCH_CHANGE, payload: {plotId, stretchData, actionScope}}); +} + +/** + * Show image with new color table loaded + * Note - function parameter is a single object + * + * + * @param {Object} obj + * @param {string} obj.plotId + * @param {number} obj.cbarId must be in the range, 0 - 21, each number represents different color bar + * @param {number} obj.bias bias between 0 - 1, .5 is no bias + * @param {number} obj.contrast bias between 0 - 2, .1 is no contrast + * @param {Array.} obj.nanPixelColor a 3 cell array of [r,g,b] + * @param {boolean} obj.useRed use this band, only use with 3 color + * @param {boolean} obj.useGreen use this band, only use with 3 color + * @param {boolean} obj.useBlue use this band, only use with 3 color + * + * @param {string|ActionScope} [obj.actionScope] default to group + * @param {Function} [obj.dispatcher] only for special dispatching uses such as remote + * + * + * @public + * @function dispatchColorChange + * @memberof firefly.action + */ +export function dispatchColorChange({ + plotId, cbarId, bias, contrast, + useRed = true, useGreen = true, useBlue = true, nanPixelColor = [0, 0, 0], + actionScope = ActionScope.GROUP, dispatcher = flux.process + }) { + dispatcher({ + type: COLOR_CHANGE, payload: { + plotId, cbarId, bias, contrast, nanPixelColor, + useRed, useGreen, useBlue, actionScope + } + }); +} + +/** + * Tweek how the API image view works + * @param {boolean} apiToolsView + * + * @public + * @function dispatchApiToolsView + * @memberof firefly.action + */ +export function dispatchApiToolsView(apiToolsView) { + flux.process({ type: API_TOOLS_VIEW , payload: { apiToolsView}}); +} + +/** + * + * @param {String} plotId - + * @param {String} message - the message if working or failure + * @param {boolean} done - true if completed, false if still working + * @param {String} requestKey + * @param {boolean} [callSuccess=true] - true if success, false otherwise, parameter ignored if done is false + */ +export function dispatchPlotProgressUpdate(plotId, message, done, requestKey, callSuccess= true ) { + flux.process({ type: PLOT_PROGRESS_UPDATE, payload: { plotId, done, message, requestKey, callSuccess }}); +} + +/** + * Notify that the size of the plot viewing area has changed + * + * @param {string} plotId + * @param {number} [width] this parameter should be the offsetWidth of the dom element + * @param {number} [height] this parameter should be the offsetHeight of the dom element + */ +export function dispatchUpdateViewSize(plotId,width,height) { + flux.process({type: UPDATE_VIEW_SIZE, payload: {plotId, width, height} }); +} + +/** + * change overlay/color lock for color change and overlays + * + * @param {string} plotId is required + * @param {boolean} overlayColorLock true to set group lockRelated on + */ +export function dispatchOverlayColorLocking(plotId,overlayColorLock) { + flux.process({ type: OVERLAY_COLOR_LOCKING, payload :{ plotId, overlayColorLock}}); +} + +/** + * Change the primary plot for a multi image fits display + * Note - function parameter is a single object + * @param {Object} p + * @param {string} p.plotId + * @param {number} p.primeIdx + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + */ +export function dispatchChangePrimePlot({plotId, primeIdx, dispatcher = flux.process}) { + dispatcher({type: CHANGE_PRIME_PLOT, payload: {plotId, primeIdx}}); +} + +/** + * set if the base image is visible on a PlotView or an OverlayPlotView + * @param {Object} p + * @param {string} p.plotId + * @param {string} [p.imageOverlayId] if defined change the visibility on the OverlayPlotView match this idea + * @param {boolean} p.visible - true if visible + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + */ +export function dispatchChangeImageVisibility({plotId, imageOverlayId, visible, dispatcher = flux.process}) { + dispatcher({type: CHANGE_IMAGE_VISIBILITY, payload: {plotId, imageOverlayId, visible}}); +} + +/** + * + /** + * change position lock for zoom and scrolling + * + * @param {string} plotId is required + * @param {boolean} positionLock true to set group lockRelated on + */ +export function dispatchPositionLocking(plotId, positionLock) { + flux.process({type: POSITION_LOCKING, payload: {plotId, positionLock}}); +} + +/** + * Rotate image, do it client side + * + * Note - function parameter is a single object + * @param {Object} p + * @param {string} p.plotId + * @param {RotateType} p.rotateType enum RotateType + * @param {number} [p.angle] - rotation angle- rotation is always toward the east of north. That is east-left images will + * rotate counter-clockwise, while east-right image will rotate clockwise + * @param {string|ActionScope} [p.actionScope] enum ActionScope + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + * + * @public + * @function dispatchRotate + * @memberof firefly.action + */ +export function dispatchRotate({ + plotId, rotateType, angle = -1, + actionScope = ActionScope.GROUP, dispatcher = flux.process + }) { + dispatcher({type: ROTATE, payload: {plotId, angle, rotateType, actionScope}}); +} + +/** + * @summary Flip + * Note - function parameter is a single object + * @param {Object} p + * @param {string} p.plotId + * @param {boolean} [p.isY] + * @param {boolean} [p.rematchAfterFlip] + * @param {string|ActionScope} [p.actionScope] enum ActionScope + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + * + * @public + * @function dispatchFlip + * @memberof firefly.action + */ +export function dispatchFlip({ + plotId, isY = true, rematchAfterFlip = true, + actionScope = ActionScope.GROUP, dispatcher = flux.process + }) { + dispatcher({type: FLIP, payload: {plotId, isY, rematchAfterFlip, actionScope}}); +} + +/** + * @summary Crop + * Note - function parameter is a single object + * @param {Object} p + * @param {string} p.plotId + * @param {Object} p.imagePt1 image point of corner 1 + * @param {Object} p.imagePt2 image point of corner 2 + * @param {boolean} p.cropMultiAll + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + * + * @public + * @function dispatchCrop + * @memberof firefly.action + */ +export function dispatchCrop({plotId, imagePt1, imagePt2, cropMultiAll, dispatcher = flux.process}) { + dispatcher({type: CROP, payload: {plotId, imagePt1, imagePt2, cropMultiAll}}); +} + +/** + * @summary Move the scroll point on this plotId and possible others if it is grouped. + * + * Note - function parameter is a single object + * @param {Object} p + * @param {string} p.plotId + * @param {Object} p.scrollPt a new point to scroll + * @param {Object} [p.disableBoundCheck] + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + */ +export function dispatchProcessScroll({plotId, scrollPt, disableBoundCheck = false, dispatcher = flux.process}) { + dispatcher({type: PROCESS_SCROLL, payload: {plotId, scrollPt, disableBoundCheck}}); +} + +/** + * + * @param {Object} p + * @param {string} p.plotId + * @param {WorldPt|undefined} [p.centerProjPt] new center, if undefined just keep the same center + * @param {boolean} [p.fullSky] if true AITOFF, false half sky, undefined then don't change + * @param {boolean} [p.doWcsImageMatching] + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + */ +export function dispatchChangeCenterOfProjection({ + plotId, + centerProjPt, + fullSky, + doWcsImageMatching, + dispatcher = flux.process + }) { + dispatcher({type: CHANGE_CENTER_OF_PROJECTION, payload: {plotId, centerProjPt, doWcsImageMatching, fullSky}}); +} + +/** + * @summary recenter the images on the plot center or the ACTIVE_TARGET + * + * Note - function parameter is a single object + * @param {Object} p + * @param {string} p.plotId + * @param {Point} [p.centerPt] Point to center on + * @param {boolean} [p.centerOnImage] only used if centerPt is not defined. If true then the centering will be + * the center of the image. If false, then the center point will be the + * FIXED_TARGET attribute, if defined. Otherwise it will be the center of the image. + * @param {boolean} [p.updateFixedTarget] if true and centerPt is a worldPt, it will update the + * FIXED_TARGET attribute on the plot + * @param {boolean} [p.updateWcsPrimId] if true update the make plotId the prime for wcs matching, defaults to true + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + * + * @public + * @function dispatchRecenter + * @memberof firefly.action + */ +export function dispatchRecenter({ + plotId, centerPt = undefined, centerOnImage = false, + updateWcsPrimId = true, + updateFixedTarget = false, dispatcher = flux.process + }) { + dispatcher({type: RECENTER, payload: {plotId, centerPt, centerOnImage, updateFixedTarget, updateWcsPrimId}}); +} + +export function dispatchMarkOutOfMemory({plotId, markOutOfMemory = true, dispatcher = flux.process}) { + dispatcher({type: MARK_OUT_OF_MEMORY, payload: {plotId, markOutOfMemory}}); +} + +/** + * @summary replot the image with the original plot parameters + * + * Note - function parameter is a single object + * @param {Object} p this function takes a single parameter + * @param {string} p.plotId + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + * @function dispatchRestoreDefaults + */ +export function dispatchRestoreDefaults({plotId, dispatcher = flux.process}) { + dispatcher({type: RESTORE_DEFAULTS, payload: {plotId}}); +} + +/** + * @summary add placeholder for a plot. message is optional and any other parameters will the passed through to the + * react component + * @param {Object} p + * @param {string} p.plotId is required unless defined in the WebPlotRequest + * @param {string} [p.message] is required unless defined in the WebPlotRequest + * @param {string} p.viewerId - viewer that this plot should be put into + * @param {Function} [p.dispatcher] only for special dispatching uses such as remote + */ +export function dispatchPlotProxy({plotId, message, viewerId, dispatcher = flux.process, ...rest}) { + dispatcher({type: PLOT_PROXY, payload: {plotId, message, viewerId, ...rest}}); +} \ No newline at end of file diff --git a/src/firefly/js/visualize/ImageViewerLayout.jsx b/src/firefly/js/visualize/ImageViewerLayout.jsx index 002bfded9a..04c2c3b12a 100644 --- a/src/firefly/js/visualize/ImageViewerLayout.jsx +++ b/src/firefly/js/visualize/ImageViewerLayout.jsx @@ -14,22 +14,18 @@ import {ImageViewerStatus} from './iv/ImageViewerStatus.jsx'; import {makeScreenPt, makeDevicePt} from './Point.js'; import {DrawerComponent} from './draw/DrawerComponent.jsx'; import {CCUtil, CysConverter} from './CsysConverter.js'; -import {UserZoomTypes} from './ZoomUtil.js'; +import {ActionScope, EXPANDED_MODE_RESERVED, ExpandType, IMAGE, MOUSE_CLICK_REASON, UserZoomTypes} from './VisConst'; +import {visRoot} from './VisStoreRoots'; +import {primePlot, hasLocalStretchByteData, getFoV, currentP} from './PlotViewUtil.js'; import { - primePlot, getPlotViewById, hasLocalStretchByteData, isActivePlotView, getFoV -} from './PlotViewUtil.js'; -import { - isImageViewerSingleLayout, getMultiViewRoot, findViewerWithItemId, IMAGE, getViewer, getExpandedViewerItemIds, - EXPANDED_MODE_RESERVED + isImageViewerSingleLayout, getMultiViewRoot, findViewerWithItemId, getViewer, getExpandedViewerItemIds, } from './MultiViewCntlr.js'; import {contains, getBoundingBox, intersects} from './VisUtil.js'; import BrowserInfo from '../util/BrowserInfo.js'; - import { - visRoot, ActionScope, dispatchPlotProgressUpdate, dispatchZoom, dispatchRecenter, dispatchProcessScroll, - dispatchChangeCenterOfProjection, dispatchChangeActivePlotView, - dispatchUpdateViewSize, dispatchRequestLocalData, MOUSE_CLICK_REASON, ExpandType, dispatchMarkOutOfMemory -} from './ImagePlotCntlr.js'; + dispatchChangeActivePlotView, dispatchChangeCenterOfProjection, dispatchMarkOutOfMemory, dispatchPlotProgressUpdate, + dispatchProcessScroll, dispatchRecenter, dispatchRequestLocalData, dispatchUpdateViewSize, dispatchZoom +} from './ImagePlotDispatch'; import {fireMouseCtxChange, makeMouseStatePayload, MouseState} from './VisMouseSync.js'; import {isHiPS, isHiPSAitoff, isImage} from './WebPlot.js'; import {plotMove} from './PlotMove'; @@ -100,12 +96,12 @@ export const ImageViewerLayout= memo(({ plotView, drawLayersAry, width, height, fireMouseEvent(dl,mouseState,mouseStatePayload); } else if (isWheel(mouseState)) { - if (!isActivePlotView(visRoot(),eventPlotId) && isWheelRequireImageActive(eventPlotId)) return; + if (!currentP(eventPlotId).active && isWheelRequireImageActive(eventPlotId)) return; handleScrollWheelEvent(plotView,mouseState,screenPt,nativeEv); return; } else if (isPinch(mouseState)) { - if (!isActivePlotView(visRoot(),eventPlotId)) return; + if (!currentP(eventPlotId).active) return; handlePinchEvent(plotView,mouseState,screenPt,nativeEv); return; } @@ -180,8 +176,7 @@ function isWheelRequireImageActive(plotId) { */ function updateZoom(plotId, paging) { const vr= visRoot(); - const pv= getPlotViewById(vr, plotId); - const plot= primePlot(pv); + const {pv,plot}= currentP(plotId); if (!plot) return; if (!pv.plotViewCtx.zoomLockingEnabled) return; @@ -277,7 +272,7 @@ const ImageViewerContents= memo(({drawLayersAry=[],plotView,eventCallback,cursor function scrollMove(plotDrag, plotId, screenX,screenY) { - const pv= getPlotViewById(visRoot(), plotId); + const {pv}= currentP(plotId); const newScrollPt= plotDrag(screenX,screenY, pv); if (isImage(primePlot(pv))) { dispatchProcessScroll({plotId,scrollPt:newScrollPt}); diff --git a/src/firefly/js/visualize/MultiViewCntlr.js b/src/firefly/js/visualize/MultiViewCntlr.js index c114b13236..86781cfcc0 100644 --- a/src/firefly/js/visualize/MultiViewCntlr.js +++ b/src/firefly/js/visualize/MultiViewCntlr.js @@ -3,31 +3,23 @@ */ import {difference, has, union, without} from 'lodash'; import {call, race, take} from 'redux-saga/effects'; -import {REINIT_APP} from '../core/AppDataCntlr.js'; + +import {REINIT_APP} from '../core/CoreConst'; import {dispatchAddSaga} from '../core/MasterSaga.js'; import {flux} from '../core/ReduxFlux.js'; -import ImagePlotCntlr, {dispatchRecenter, visRoot} from './ImagePlotCntlr.js'; -import {ExpandType, WcsMatchType, IMAGE, EXPANDED_MODE_RESERVED, NewPlotMode} from './VisConst.js'; -export {IMAGE, EXPANDED_MODE_RESERVED, NewPlotMode} from './VisConst.js'; + +import {dispatchRecenter} from './ImagePlotDispatch'; import {PlotAttribute} from './PlotAttribute.js'; import {getPlotViewById, primePlot} from './PlotViewUtil.js'; - -export const META_VIEWER_ID = 'triViewImageMetaData'; -export const IMAGE_MULTI_VIEW_KEY= 'imageMultiView'; -export const IMAGE_MULTI_VIEW_PREFIX= 'MultiViewCntlr'; - -export const ADD_VIEWER= `${IMAGE_MULTI_VIEW_PREFIX}.AddViewer`; -export const REMOVE_VIEWER= `${IMAGE_MULTI_VIEW_PREFIX}.RemoveViewer`; -export const VIEWER_MOUNTED= `${IMAGE_MULTI_VIEW_PREFIX}.viewMounted`; -export const VIEWER_UNMOUNTED= `${IMAGE_MULTI_VIEW_PREFIX}.viewUnmounted`; -export const VIEWER_SCROLL= `${IMAGE_MULTI_VIEW_PREFIX}.viewScroll`; -export const BOTTOM_UI_COMPONENT= `${IMAGE_MULTI_VIEW_PREFIX}.bottomUIComponent`; -export const ADD_VIEWER_ITEMS= `${IMAGE_MULTI_VIEW_PREFIX}.addViewerItems`; -export const REMOVE_VIEWER_ITEMS= `${IMAGE_MULTI_VIEW_PREFIX}.removeViewerItems`; -export const REPLACE_VIEWER_ITEMS= `${IMAGE_MULTI_VIEW_PREFIX}.replaceViewerItems`; -export const CHANGE_VIEWER_LAYOUT= `${IMAGE_MULTI_VIEW_PREFIX}.changeViewerLayout`; -export const UPDATE_VIEWER_CUSTOM_DATA= `${IMAGE_MULTI_VIEW_PREFIX}.updateViewerCustomData`; -export const ADD_TO_AUTO_RECEIVER = `${IMAGE_MULTI_VIEW_PREFIX}.addToAutoReceiver`; +import { + ADD_TO_AUTO_RECEIVER, ADD_VIEWER, ADD_VIEWER_ITEMS, BOTTOM_UI_COMPONENT, CHANGE_ACTIVE_PLOT_VIEW, + CHANGE_VIEWER_LAYOUT, DEFAULT_FITS_VIEWER_ID, DEFAULT_PLOT2D_VIEWER_ID, DELETE_PLOT_VIEW, EXPANDED_MODE_RESERVED, + ExpandType, GRID, GRID_FULL, IMAGE, IMAGE_MULTI_VIEW_KEY, META_VIEWER_ID, NewPlotMode, PLOT2D, PLOT_HIPS, + PLOT_IMAGE, PLOT_IMAGE_START, PLOT_PROXY, REMOVE_PROXY, REMOVE_VIEWER, REMOVE_VIEWER_ITEMS, REPLACE_VIEWER_ITEMS, + SINGLE, UPDATE_VIEW_SIZE, UPDATE_VIEWER_CUSTOM_DATA, VIEWER_MOUNTED, VIEWER_SCROLL, VIEWER_UNMOUNTED, WcsMatchType, + WRAPPER, +} from './VisConst.js'; +import {visRoot} from './VisStoreRoots'; /** @@ -36,25 +28,12 @@ export const ADD_TO_AUTO_RECEIVER = `${IMAGE_MULTI_VIEW_PREFIX}.addToAutoReceive export const getMultiViewRoot= () => flux.getState()[IMAGE_MULTI_VIEW_KEY]; export default { + reducer, reducers: () => ({[IMAGE_MULTI_VIEW_KEY]: reducer}), actionCreators: () => ({ [CHANGE_VIEWER_LAYOUT]: changeViewerLayoutActionCreator }), - ADD_VIEWER, REMOVE_VIEWER, ADD_VIEWER_ITEMS, REMOVE_VIEWER_ITEMS, REPLACE_VIEWER_ITEMS, - VIEWER_MOUNTED, VIEWER_UNMOUNTED, UPDATE_VIEWER_CUSTOM_DATA, CHANGE_VIEWER_LAYOUT, - reducer }; -export const SINGLE='single'; -export const GRID='grid'; -// IMAGE and EXPANDED_MODE_RESERVED are defined in VisConst.js and re-exported above. -export const PLOT2D='plot2d'; -export const WRAPPER='wrapper'; -export const DEFAULT_FITS_VIEWER_ID= 'DEFAULT_FITS_VIEWER_ID'; -export const DEFAULT_PLOT2D_VIEWER_ID= 'DEFAULT_PLOT2D_VIEWER_ID'; -export const PINNED_CHART_VIEWER_ID = 'PINNED_CHART_VIEWER_ID'; -export const GRID_RELATED='gridRelated'; -export const GRID_FULL='gridFull'; - // NewPlotMode is defined in VisConst.js and re-exported above. function initState() { @@ -259,7 +238,7 @@ export function* watchForResizing(options) { while (waitingForMore) { const raceWinner = yield race({ - action: take([ImagePlotCntlr.UPDATE_VIEW_SIZE]), + action: take([UPDATE_VIEW_SIZE]), timer: call(delay, 1000) }); const {action}= raceWinner; @@ -275,7 +254,7 @@ export function* watchForResizing(options) { const vr= visRoot(); const pv= getPlotViewById(vr, vr.mpwWcsPrimId); - if (pv && primePlot(vr, pv) && vr.wcsMatchType) { + if (primePlot(pv) && vr.wcsMatchType) { const centerOnImage= ( vr.wcsMatchType===WcsMatchType.Standard || vr.wcsMatchType===WcsMatchType.Pixel || @@ -382,18 +361,14 @@ export const findViewerWithItemId= (multiViewRoot, itemId, containerType) => entry.containerType===containerType)?.viewerId; /** - * * @param {MultiViewerRoot} multiViewRoot * @param {string} containerType - * @param {string} [renderTreeId] - used only with multiple rendered tree, like slate in jupyter lab * @return {Viewer} */ -export function getAViewFromMultiView(multiViewRoot, containerType, renderTreeId= undefined) { - const viewer= multiViewRoot.find((entry) => (!entry.viewerId.includes('RESERVED')&& - !entry.customData.independentLayout && - entry.containerType===containerType && - (entry?.canReceiveNewPlots===NewPlotMode.create_replace.key))); - return viewer; +export function getAViewFromMultiView(multiViewRoot, containerType) { + return multiViewRoot.find( + (entry) => (!entry.viewerId.includes('RESERVED') && !entry.customData.independentLayout && + entry.containerType===containerType && (entry?.canReceiveNewPlots===NewPlotMode.create_replace.key))); } /** @@ -452,18 +427,18 @@ function reducer(state=initState(), action={}) { return changeBottomUIComponent(state,payload.viewerId,payload.bottomUIComponent); case UPDATE_VIEWER_CUSTOM_DATA: return updateCustomData(state,action); - case ImagePlotCntlr.DELETE_PLOT_VIEW: - case ImagePlotCntlr.REMOVE_PROXY: + case DELETE_PLOT_VIEW: + case REMOVE_PROXY: return deleteSingleItem(state,payload.plotId, IMAGE); - case ImagePlotCntlr.PLOT_HIPS: - case ImagePlotCntlr.PLOT_IMAGE_START: - case ImagePlotCntlr.PLOT_PROXY: + case PLOT_HIPS: + case PLOT_IMAGE_START: + case PLOT_PROXY: const {viewerId, plotId, renderTreeId, pvOptions:{canBeExpanded= true}={} } = payload; if (!imageViewerCanAdd(state,viewerId, plotId)) return state; state= addItems(state,payload.viewerId,[payload.plotId], IMAGE, renderTreeId); return canBeExpanded ? addItems(state,EXPANDED_MODE_RESERVED,[payload.plotId],IMAGE) : state; - case ImagePlotCntlr.CHANGE_ACTIVE_PLOT_VIEW: - case ImagePlotCntlr.PLOT_IMAGE: + case CHANGE_ACTIVE_PLOT_VIEW: + case PLOT_IMAGE: return changeActiveItem(state, payload, IMAGE); case REINIT_APP: return initState(); diff --git a/src/firefly/js/visualize/PlotCompleteMonitor.js b/src/firefly/js/visualize/PlotCompleteMonitor.js index dd06e84517..276db96640 100644 --- a/src/firefly/js/visualize/PlotCompleteMonitor.js +++ b/src/firefly/js/visualize/PlotCompleteMonitor.js @@ -1,7 +1,9 @@ import {isString} from 'lodash'; -import ImagePlotCntlr, {visRoot} from './ImagePlotCntlr'; +import { + ABORT_HIPS, DELETE_PLOT_VIEW, PLOT_HIPS, PLOT_HIPS_FAIL, PLOT_IMAGE, PLOT_IMAGE_FAIL, UPDATE_VIEW_SIZE +} from './VisConst'; import {dispatchAddActionWatcher} from '../core/MasterSaga'; -import {getPlotViewById, primePlot} from './PlotViewUtil'; +import {currentP, primePlot} from './PlotViewUtil'; /* @@ -15,9 +17,9 @@ import {getPlotViewById, primePlot} from './PlotViewUtil'; */ export function onPlotComplete(plotId, failureAsReject = false) { - const failActions = [ImagePlotCntlr.ABORT_HIPS, ImagePlotCntlr.PLOT_HIPS_FAIL, ImagePlotCntlr.PLOT_IMAGE_FAIL]; - const succActions = [ImagePlotCntlr.PLOT_HIPS, ImagePlotCntlr.PLOT_IMAGE]; - const pv = plotId && getPlotViewById(visRoot(), plotId); + const failActions = [ABORT_HIPS, PLOT_HIPS_FAIL, PLOT_IMAGE_FAIL]; + const succActions = [PLOT_HIPS, PLOT_IMAGE]; + const {pv} = currentP(plotId); if (pv && pv.serverCall !== 'working' && primePlot(pv) && pv.viewDim.width && pv.viewDim.height) { if (pv.serverCall === 'success') { return Promise.resolve(pv); @@ -28,7 +30,7 @@ export function onPlotComplete(plotId, failureAsReject = false) { return new Promise((resolve, reject) => { dispatchAddActionWatcher({ - actions: [...succActions, ...failActions, ImagePlotCntlr.UPDATE_VIEW_SIZE], + actions: [...succActions, ...failActions, UPDATE_VIEW_SIZE], callback: watchViewDim, params: {plotId, resolve, reject, failureAsReject, failActions, succActions} } @@ -40,8 +42,7 @@ function watchViewDim(action, cancelSelf, {plotId, resolve, reject, failureAsRej if (!resolve) cancelSelf(); if (action.payload.plotId !== plotId) return; const {type} = action; - const vr = visRoot(); - const pv = getPlotViewById(vr, plotId); + const {pv}= currentP(plotId); const {width=0, height=0} = pv?.viewDim ?? {}; if (failActions.includes(type)) { failureAsReject ? reject(Error(action)) : resolve(); @@ -49,7 +50,7 @@ function watchViewDim(action, cancelSelf, {plotId, resolve, reject, failureAsRej return; } if (succActions.includes(type)) foundSuccComplete = true; - if (action.type===ImagePlotCntlr.UPDATE_VIEW_SIZE) foundSuccComplete = true; + if (action.type===UPDATE_VIEW_SIZE) foundSuccComplete = true; if (foundSuccComplete && width > 30 && height > 30) { resolve(pv); cancelSelf(); @@ -70,9 +71,9 @@ export async function onViewDimDefined(plotIdAryOrPlotId) { function onViewDimDefinedWatcher(action, cancelSelf, {plotId, resolve, startTime}) { const {type, payload} = action; - const pv = getPlotViewById(visRoot(), plotId); + const {pv}= currentP(plotId); let resolvedViewDim; - if ((payload.plotId !== plotId && type===ImagePlotCntlr.DELETE_PLOT_VIEW) || !pv) resolvedViewDim= {width:0,height:0}; + if ((payload.plotId !== plotId && type===DELETE_PLOT_VIEW) || !pv) resolvedViewDim= {width:0,height:0}; if (pv?.viewDim?.width>0 && pv?.viewDim?.height>0) resolvedViewDim= pv.viewDim; if (Date.now() > (startTime +10_000)) resolvedViewDim= {width:0,height:0}; if (resolvedViewDim) { @@ -83,11 +84,11 @@ function onViewDimDefinedWatcher(action, cancelSelf, {plotId, resolve, startTime } function resolveViewDimPromise(plotId) { - const pv= getPlotViewById(visRoot(),plotId); + const {pv}= currentP(plotId); if (pv?.viewDim.width>0 && pv?.viewDim.height>0 ) return Promise.resolve(pv.viewDim); return new Promise((resolve) => { dispatchAddActionWatcher({ - actions: [ImagePlotCntlr.UPDATE_VIEW_SIZE, ImagePlotCntlr.DELETE_PLOT_VIEW], + actions: [UPDATE_VIEW_SIZE, DELETE_PLOT_VIEW], callback: onViewDimDefinedWatcher, params: {plotId, resolve, startTime: Date.now()} } ); }); diff --git a/src/firefly/js/visualize/PlotViewUtil.js b/src/firefly/js/visualize/PlotViewUtil.js index ee67d82d7c..11866edc14 100644 --- a/src/firefly/js/visualize/PlotViewUtil.js +++ b/src/firefly/js/visualize/PlotViewUtil.js @@ -1,7 +1,12 @@ /* * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import {dispatchDeletePlotView, ExpandType, visRoot} from 'firefly/visualize/ImagePlotCntlr.js'; +import {flux} from '../core/ReduxFlux'; +import {visRoot} from './VisStoreRoots'; +import { + CANVAS_DL_ID_START, CANVAS_IMAGE_ID_START, DEFAULT_COVERAGE_PLOT_ID, + DEFAULT_COVERAGE_VIEWER_ID, DELETE_PLOT_VIEW, ExpandType +} from './VisConst'; import {has, isArray, isEmpty, isObject, isString, isUndefined} from 'lodash'; import shallowequal from 'shallowequal'; import {memorizeLastCall} from '../util/WebUtil'; @@ -22,11 +27,6 @@ import {computeDistance, WAVELENGTH_UNITS} from './VisUtil'; import {isHiPS, isHiPSAitoff, isImage} from './WebPlot.js'; -export const CANVAS_IMAGE_ID_START= 'image-'; -export const CANVAS_DL_ID_START= 'dl-'; -export const DEFAULT_COVERAGE_PLOT_ID = 'CoveragePlot'; -export const DEFAULT_COVERAGE_VIEWER_ID = 'CoverageImages'; - /** * * @param {VisRoot | PlotView[]| undefined} ref @@ -42,7 +42,7 @@ export function getPlotViewAry(ref, plotGroupId= undefined) { else if (isArray(ref) && ref.length>0 && ref[0].plotId) { // passed a plotViewAry pvAry= ref; } - if (!plotGroupId) return pvAry; + if (!plotGroupId) return pvAry ?? []; return pvAry.filter( (pv) => pv.plotGroupId===plotGroupId); } @@ -67,7 +67,7 @@ export const primePlot= memorizeLastCall( (ref,plotId) => { else if (plotId && isArray(ref) && ref.length>0 && ref[0].plotId) { //i was passed a plotViewAry pv= ref.find( (pv) => pv.plotId===plotId); } - else if (ref.plotId && ref.plots) { // i was passed a plotView + else if (isPlotView(ref)) { // i was passed a plotView pv= ref; } return (pv && pv.primeIdx>=0) ? pv.plots[pv.primeIdx] : undefined; @@ -95,23 +95,29 @@ export const getPlotViewById= memorizeLastCall( (ref,plotId) =>{ /** * get the newest version of a plot or a plotview from the store + * important - do not call from a reducer * @param {WebPlot|PlotView|undefined} plotOrPv * @return {WebPlot|PlotView|undefined} the new version */ export function refreshP(plotOrPv) { if (!plotOrPv?.plotId) return; - if (plotOrPv.plots && plotOrPv.primeIdx>=0) return getPlotViewById(visRoot(), plotOrPv.plotId); + if (isPlotView(plotOrPv)) return getPlotViewById(visRoot(), plotOrPv.plotId); if (plotOrPv.plotImageId) return primePlot(visRoot(), plotOrPv.plotId); } - -export function refreshPlotView(pv) { - return getPlotViewById(visRoot(), pv?.plotId); +/** + * return a object with PlotView, prime WebPlot for the PlotView, the plotId, and is active3 + * !!! important - do not call from a reducer + * @param {String} [plotId] - if defined return the PlotView and prime WebPlot for that plotId, if undefined return the active. + * @return {{pv:PlotView, plot:WebPlot, plotId:String, active:boolean}} + */ +export function currentP(plotId) { + const vr= visRoot(); + const pv= plotId ? getPlotViewById(vr, plotId) : getActivePlotView(vr); + const currentPlotId= plotId ?? pv?.plotId; + return {pv, plot:primePlot(pv), plotId: currentPlotId , active:isActivePlotView(vr, currentPlotId)}; } -export function refreshPlot(plot) { - return primePlot(visRoot(), plot?.plotId); -} export const getPlotViewIdxById= (ref,plotId) => plotId && getPlotViewAry(ref)?.findIndex( (pv) => pv.plotId===plotId); @@ -137,7 +143,7 @@ export function hasWCSProjection(ref, includeNoncelestial=false) { if (!ref) return false; const projection= ref.projection ?? primePlot(ref)?.projection; const hasProjection = Boolean(projection?.isSpecified() && projection?.isImplemented()); - return hasProjection && projection?.coordSys?.isCelestial() || includeNoncelestial; + return includeNoncelestial ? hasProjection : hasProjection && projection?.coordSys?.isCelestial(); } /** @@ -173,7 +179,7 @@ export function getPlotViewIdListInOverlayGroup(visRoot,pvOrId) { /** * return an array of plotIds that are all under visRoot and based on the overlay/color lock of the group associated - * width the pvOrId parameter + * with the pvOrId parameter * @param visRoot * @param pvOrId * @param hasPlots @@ -229,7 +235,7 @@ export function isThreeColor(plotOrPv) { * @param obj * @return boolean */ -export const isPlotView= (obj) => +const isPlotView= (obj) => isObject(obj) && Boolean(obj.plots && obj.plotId && obj.viewDim && obj.overlayPlotViews && obj.plotViewCtx); @@ -712,13 +718,13 @@ export function getAllCanvasLayersForPlot(plotId) { .sort( (c1,c2) => { const n1= getCanvasIdx(c1,CANVAS_IMAGE_ID_START,plotId); const n2= getCanvasIdx(c2,CANVAS_IMAGE_ID_START,plotId); - return n1 canvas.id.startsWith(CANVAS_DL_ID_START)) .sort( (c1,c2) => { const n1= getCanvasIdx(c1,CANVAS_DL_ID_START,plotId); const n2= getCanvasIdx(c2,CANVAS_DL_ID_START,plotId); - return n1 pv?.plotViewCtx.hduPlotStartIndexes * @param {PlotView} pv * @return {Number} */ -export const getHDUCount= (pv) => getHduPlotStartIndexes(pv).length; +export const getHDUCount= (pv) => getHduPlotStartIndexes?.(pv).length ?? 0; /** @@ -849,6 +855,7 @@ export function getHDUIndex(pv, plot= undefined) { const p= plot || primePlot(pv); const plotIdx= pv.plots.findIndex( (testP) => testP===p); const startIndexes= getHduPlotStartIndexes(pv); + if (!startIndexes) return 0; const hduIdx= startIndexes.findIndex( (value,arrayIdx) => value<=plotIdx && (arrayIdx===startIndexes.length-1 || startIndexes[arrayIdx+1]>plotIdx )); return hduIdx; } @@ -1045,7 +1052,7 @@ export function isPlotViewsEqual(pv1, pv2, pvKeys=[], plotKeys=[]) { if (Boolean(p1)!==Boolean(p2)) return false; if (p1 && p2) { - if (isImage(p1) !== isImage(p1)) return false; + if (isImage(p1) !== isImage(p2)) return false; if (isEmpty(plotKeys)) { if (p1 !== p2) return false; } else { @@ -1057,8 +1064,8 @@ export function isPlotViewsEqual(pv1, pv2, pvKeys=[], plotKeys=[]) { } export function isPlotViewArysEqual(pvAry1, pvAry2, pvKeys=[], plotKeys=[]) { - if (isEmpty(pvAry1) && isEmpty(pvAry1)) return true; - if (isEmpty(pvAry1)!==isEmpty(pvAry1)) return false; + if (isEmpty(pvAry1) && isEmpty(pvAry2)) return true; + if (isEmpty(pvAry1)!==isEmpty(pvAry2)) return false; if (pvAry1.length!==pvAry2.length) return false; return pvAry1.every( (pv,idx) => isPlotViewsEqual(pv,pvAry2[idx], pvKeys, plotKeys)); } @@ -1162,7 +1169,7 @@ export function isAllStretchDataLoaded(vr) { * @returns {boolean} */ export function isDefaultCoverageActive(vr, mvr) { - if (getActivePlotView(vr)?.plotId!==DEFAULT_COVERAGE_PLOT_ID) return false; + if (currentP().plotId!==DEFAULT_COVERAGE_PLOT_ID) return false; return Boolean(getViewer(mvr,DEFAULT_COVERAGE_VIEWER_ID)?.mounted); } @@ -1176,9 +1183,9 @@ export const isImageExpanded = (expandedMode) => expandedMode === true || * @param {VisRoot} [vr] */ export const deleteAllFailedPlots = (vr= visRoot()) => - getPlotViewAry(vr) + getPlotViewAry(vr) // don't use dispatchDeletePlotView to save circular dependency .filter((pv) => pv.serverCall === 'fail') - .forEach(({plotId}) => dispatchDeletePlotView({plotId})); // set 20 as the maximum plot + .forEach(({plotId}) => flux.process({ type: DELETE_PLOT_VIEW, payload: {plotId} }) ); diff --git a/src/firefly/js/visualize/RelatedDataUtil.js b/src/firefly/js/visualize/RelatedDataUtil.js index 7c33962784..44dcef1a47 100644 --- a/src/firefly/js/visualize/RelatedDataUtil.js +++ b/src/firefly/js/visualize/RelatedDataUtil.js @@ -2,23 +2,16 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import {isEmpty, get, flatten, values, uniq} from 'lodash'; +import {isEmpty, get, flatten, uniq} from 'lodash'; +import {dispatchAttachLayerToPlot, dispatchCreateDrawLayer} from './DrawLayerDispatch'; import { primePlot, getPlotViewIdListInOverlayGroup, getPlotViewById, operateOnOthersInOverlayColorGroup} from './PlotViewUtil.js'; import {WPConst} from './WebPlotRequest.js'; import {RDConst} from './WebPlot.js'; -import { - visRoot, dispatchPlotMask, dispatchPlotMaskLazyLoad, dispatchChangeImageVisibility -} from './ImagePlotCntlr.js'; -import {dispatchCreateDrawLayer, dispatchAttachLayerToPlot} from './DrawLayerCntlr.js'; +import {dispatchChangeImageVisibility, dispatchPlotMask, dispatchPlotMaskLazyLoad} from './ImagePlotDispatch'; +import {visRoot} from './VisStoreRoots'; import Artifact from '../drawingLayers/Artifact.js'; - - - - - - //-------------------------------------------------------------- //-------------------------------------------------------------- //--------- related data and OverlayPlotView functions diff --git a/src/firefly/js/visualize/SearchRefinementTool.jsx b/src/firefly/js/visualize/SearchRefinementTool.jsx index 18151c61b1..71bdd066ae 100644 --- a/src/firefly/js/visualize/SearchRefinementTool.jsx +++ b/src/firefly/js/visualize/SearchRefinementTool.jsx @@ -16,9 +16,9 @@ import {useFieldGroupValue, useStoreConnector} from '../ui/SimpleComponent.jsx'; import {SizeInputFields} from '../ui/SizeInputField.jsx'; import {DEF_TARGET_PANEL_KEY, TargetPanel} from '../ui/TargetPanel.jsx'; import {ToolbarButton} from '../ui/ToolbarButton.jsx'; -import {dispatchDestroyDrawLayer, getDlAry} from './DrawLayerCntlr.js'; -import {visRoot} from './ImagePlotCntlr.js'; -import {getDrawLayerByType, getPlotViewById, primePlot} from './PlotViewUtil.js'; + +import {dispatchDestroyDrawLayer} from './DrawLayerDispatch'; +import {getDrawLayerByType, primePlot, currentP} from './PlotViewUtil.js'; import {parseWorldPt} from './Point.js'; import {CONE_AREA_OPTIONS, CONE_CHOICE_KEY, POLY_CHOICE_KEY} from './ui/CommonUIKeys.js'; import {SelectAreaButton} from './ui/SelectAreaUIComponents.jsx'; @@ -27,6 +27,7 @@ import { convertStrToWpAry, convertWpAryToStr, initSearchSelectTool, markOutline, SEARCH_REFINEMENT_DIALOG_ID, updateModalEndInfo, updatePlotOverlayFromUserInput, updateUIFromPlot } from './ui/VisualSearchUtils.js'; +import {getDlAry} from './VisStoreRoots'; export const POLY_CONE= 'POLY_CONE'; const SIZE_KEY= 'SIZE'; @@ -44,7 +45,7 @@ export function showSearchRefinementTool({popupClosing, element, plotId, cone, popupClosing?.(); const dl = getDrawLayerByType(getDlAry(), SearchSelectTool.TYPE_ID); if (dl?.isInteractive) { - dispatchDestroyDrawLayer(dl.drawLayerId) + dispatchDestroyDrawLayer(dl.drawLayerId); closeToolbarModalLayers(); } }; @@ -84,7 +85,7 @@ function SearchRefinementTool({searchActions, plotId, searchAreaInDeg, wp, polyg const modalEndInfo = useStoreConnector(() => getModalEndInfo()); - const pv= useStoreConnector(() => getPlotViewById(visRoot(),plotId)); + const pv= useStoreConnector(() => currentP(plotId).pv); const [getConeAreaOp,setConeAreaOp] = useFieldGroupValue(CONE_AREA_KEY, GROUP_KEY); const [getWP,setWP] = useFieldGroupValue(DEF_TARGET_PANEL_KEY, GROUP_KEY); const [getPoly,setPoly] = useFieldGroupValue(POLYGON_KEY, GROUP_KEY); @@ -97,13 +98,15 @@ function SearchRefinementTool({searchActions, plotId, searchAreaInDeg, wp, polyg const whichOverlay= searchTypes===POLY_CONE ? getConeAreaOp() : searchTypes===CONE_CHOICE_KEY ? CONE_CHOICE_KEY : POLY_CHOICE_KEY; - const getWhichOverlay= () => searchTypes===POLY_CONE ? getConeAreaOp() : - searchTypes===CONE_CHOICE_KEY ? CONE_CHOICE_KEY : POLY_CHOICE_KEY + const getWhichOverlay= () => + searchTypes===POLY_CONE + ? getConeAreaOp() + : searchTypes===CONE_CHOICE_KEY + ? CONE_CHOICE_KEY + : POLY_CHOICE_KEY; const setWhichOverlay= (op) => { (searchTypes===POLY_CONE) && setConeAreaOp(op); }; - const whichOveraly= getWhichOverlay(); - useEffect(() => { initSearchSelectTool(plotId); @@ -228,7 +231,7 @@ function SearchDropDown({searchActions, cenWpt, size, polyStr, whichOverlay}) { visible={sa.supported()} onClick={() => { markOutline(sa, - primePlot(visRoot())?.plotId,{ + currentP()?.plotId,{ wp:cenWpt, radius:Number(getValidSize(sa,size)), polyStr}); diff --git a/src/firefly/js/visualize/VisConst.js b/src/firefly/js/visualize/VisConst.js index 266109516d..b9de2ff90f 100644 --- a/src/firefly/js/visualize/VisConst.js +++ b/src/firefly/js/visualize/VisConst.js @@ -2,23 +2,227 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -/** - * Pure constants extracted from ImagePlotCntlr.js and MultiViewCntlr.js into a - * separate leaf file to break the circular dependency between those two modules. - * - * ImagePlotCntlr ↔ MultiViewCntlr form a circular dep. When Rollup bundles - * ApiUtilImage.jsx (which re-exports from both) into a namespace, it serialises - * module evaluation order. Because the cycle defers one module's body, the - * `const` values it owns can still be in the Temporal Dead Zone when the - * namespace object is constructed, causing a ReferenceError at load time. - * - * Placing these constants here, with no dependency on either controller file, - * ensures Rollup initialises them before the namespace object is built. - */ import Enum from 'enum'; -// ─── From ImagePlotCntlr.js ────────────────────────────────────────────────── +// redux store object keys +export const IMAGE_PLOT_KEY = 'allPlots'; +export const IMAGE_MULTI_VIEW_KEY = 'imageMultiView'; +export const DRAWING_LAYER_KEY = 'drawLayers'; + + +// for reason parameter of CHANGE_ACTIVE_PLOT_VIEW action +export const MOUSE_CLICK_REASON = 'mouseClickReason'; +export const OTHER_REASON = 'otherReason'; + + +// action name prefixes +export const PLOTS_PREFIX = 'ImagePlotCntlr'; +export const IMAGE_MULTI_VIEW_PREFIX = 'MultiViewCntlr'; +export const DRAWLAYER_PREFIX = 'DrawLayerCntlr'; + + + +// MultiViewCntlr container types for Viewer.containerType +export const IMAGE = 'image'; +export const PLOT2D = 'plot2d'; +export const WRAPPER = 'wrapper'; + + +// use by DrawingLayerCntrl +export const SUBGROUP = 'subgroup'; + + + +// Reserved IDs for containers and plot groups +export const EXPANDED_MODE_RESERVED = 'EXPANDED_MODE_RESERVED'; +export const DEFAULT_FITS_VIEWER_ID = 'DEFAULT_FITS_VIEWER_ID'; +export const DEFAULT_PLOT2D_VIEWER_ID = 'DEFAULT_PLOT2D_VIEWER_ID'; +export const PINNED_CHART_VIEWER_ID = 'PINNED_CHART_VIEWER_ID'; +export const DEFAULT_COVERAGE_PLOT_ID = 'CoveragePlot'; +export const DEFAULT_COVERAGE_VIEWER_ID = 'CoverageImages'; +export const META_VIEWER_ID = 'triViewImageMetaData'; + + +// type of Viewer.layout +export const SINGLE = 'single'; +export const GRID = 'grid'; + +// types of grid layouts for Viewer.layoutDetail +export const GRID_RELATED = 'gridRelated'; +export const GRID_FULL = 'gridFull'; + +// partial id constants +export const CANVAS_IMAGE_ID_START = 'image-'; +export const CANVAS_DL_ID_START = 'dl-'; + +// constants use by drawing layers +export const RegionSelectStyle = ['UprightBox', 'DottedOverlay', 'SolidOverlay', 'DottedReplace', 'SolidReplace']; +export const defaultRegionSelectColor = '#DAA520'; // golden +export const defaultRegionSelectStyle = RegionSelectStyle[0]; +export const RegionSelColor = 'selectColor'; +export const RegionSelStyle = 'selectStyle'; + + +// ---------------------------------------- +// actions use by ImagePlotCntlr +// ---------------------------------------- +/** Action Type: plot of new image started */ +export const PLOT_IMAGE_START = `${PLOTS_PREFIX}.PlotImageStart`; +/** Action Type: plot of new image failed */ +export const PLOT_IMAGE_FAIL = `${PLOTS_PREFIX}.PlotImageFail`; +/** Action Type: plot of new image completed */ +export const PLOT_IMAGE = `${PLOTS_PREFIX}.PlotImage`; +export const PLOT_PROXY = `${PLOTS_PREFIX}.PlotProxy`; +export const REMOVE_PROXY = `${PLOTS_PREFIX}.RemoveProxy`; +/** Action Type: plot of new HiPS image */ +export const PLOT_HIPS = `${PLOTS_PREFIX}.PlotHiPS`; +export const ABORT_HIPS = `${PLOTS_PREFIX}.AbortHiPS`; +export const CHANGE_HIPS = `${PLOTS_PREFIX}.ChangeHiPS`; +export const PLOT_HIPS_OR_IMAGE = `${PLOTS_PREFIX}.plotHiPSOrImage`; +export const PLOT_HIPS_FAIL = `${PLOTS_PREFIX}.PlotHiPSFail`; +/** Action Type: A image replot occurred */ +export const ANY_REPLOT = `${PLOTS_PREFIX}.Replot`; +/** Action Type: start the zoom process. The image will appear zoomed by scaling, the server has not updated yet */ +export const ZOOM_HIPS = `${PLOTS_PREFIX}.ZoomHiPS`; +/** Action Type: The zoom from the server has complete */ +export const ZOOM_IMAGE = `${PLOTS_PREFIX}.ZoomImage`; +export const ZOOM_LOCKING = `${PLOTS_PREFIX}.ZoomEnableLocking`; +/** Action Type: image with new color table loaded */ +export const COLOR_CHANGE = `${PLOTS_PREFIX}.ColorChange`; +/** Action Type: image loaded with new stretch */ +export const STRETCH_CHANGE = `${PLOTS_PREFIX}.StretchChange`; +/** Action Type: image rotated */ +export const ROTATE = `${PLOTS_PREFIX}.Rotate`; +/** Action Type: image flipped */ +export const FLIP = `${PLOTS_PREFIX}.Flip`; +export const CROP_START = `${PLOTS_PREFIX}.CropStart`; +/** Action Type: image cropped */ +export const CROP = `${PLOTS_PREFIX}.Crop`; +export const CROP_FAIL = `${PLOTS_PREFIX}.CropFail`; +export const UPDATE_VIEW_SIZE = `${PLOTS_PREFIX}.UpdateViewSize`; +export const PROCESS_SCROLL = `${PLOTS_PREFIX}.ProcessScroll`; +export const CHANGE_CENTER_OF_PROJECTION = `${PLOTS_PREFIX}.changeCenterOfProjection`; +/** Action Type: Recenter in image on the active target */ +export const RECENTER = `${PLOTS_PREFIX}.recenter`; +export const MARK_OUT_OF_MEMORY = `${PLOTS_PREFIX}.makeOutOfMemory`; +/** Action Type: replot the image with the original plot parameters */ +export const RESTORE_DEFAULTS = `${PLOTS_PREFIX}.restoreDefaults`; +export const POSITION_LOCKING = `${PLOTS_PREFIX}.PositionLocking`; +export const OVERLAY_COLOR_LOCKING = `${PLOTS_PREFIX}.OverlayColorLocking`; +export const CHANGE_POINT_SELECTION = `${PLOTS_PREFIX}.ChangePointSelection`; +export const CHANGE_ACTIVE_PLOT_VIEW = `${PLOTS_PREFIX}.ChangeActivePlotView`; +export const CHANGE_SUBHIGHLIGHT_PLOT_VIEW = `${PLOTS_PREFIX}.ChangeSubHighlightPlotView`; +export const CHANGE_PLOT_ATTRIBUTE = `${PLOTS_PREFIX}.ChangePlotAttribute`; +/** Action Type: display mode to or from expanded */ +export const CHANGE_EXPANDED_MODE = `${PLOTS_PREFIX}.changeExpandedMode`; +/** Action Type: turn on/off expanded auto-play */ +export const EXPANDED_AUTO_PLAY = `${PLOTS_PREFIX}.expandedAutoPlay`; +/** Action Type: change the primary plot for a multi image fits display */ +export const CHANGE_PRIME_PLOT = `${PLOTS_PREFIX}.changePrimePlot`; +export const CHANGE_IMAGE_VISIBILITY = `${PLOTS_PREFIX}.changeImageVisibility`; +export const CHANGE_MOUSE_READOUT_MODE = `${PLOTS_PREFIX}.changeMouseReadoutMode`; +/** Action Type: delete a plotView */ +export const DELETE_PLOT_VIEW = `${PLOTS_PREFIX}.deletePlotView`; +export const BYTE_DATA_REFRESH = `${PLOTS_PREFIX}.byteDataRefresh`; +export const PLOT_MASK_START = `${PLOTS_PREFIX}.plotMaskStart`; +/** Action Type: add a mask image*/ +export const PLOT_MASK = `${PLOTS_PREFIX}.plotMask`; +export const PLOT_MASK_LAZY_LOAD = `${PLOTS_PREFIX}.plotMaskLazyLoad`; +export const PLOT_MASK_FAIL = `${PLOTS_PREFIX}.plotMaskFail`; +export const DELETE_OVERLAY_PLOT = `${PLOTS_PREFIX}.deleteOverlayPlot`; +export const OVERLAY_PLOT_CHANGE_ATTRIBUTES = `${PLOTS_PREFIX}.overlayPlotChangeAttributes`; +export const CHANGE_HIPS_IMAGE_CONVERSION = `${PLOTS_PREFIX}.changeHipsImageConversion`; +export const CHANGE_TABLE_AUTO_SCROLL = `${PLOTS_PREFIX}.changeTableAutoScroll`; +export const USE_TABLE_AUTO_SCROLL = `${PLOTS_PREFIX}.useTableAutoScroll`; +export const REQUEST_LOCAL_DATA = `${PLOTS_PREFIX}.requestLocalData`; +/** Action Type: enable/disable wcs matching*/ +export const WCS_MATCH = `${PLOTS_PREFIX}.wcsMatch`; +export const PLOT_PROGRESS_UPDATE = `${PLOTS_PREFIX}.PlotProgressUpdate`; +export const API_TOOLS_VIEW = `${PLOTS_PREFIX}.apiToolsView`; + + +// ---------------------------------------- +// actions use by MultiViewCntlr +// ---------------------------------------- + +export const ADD_VIEWER = `${IMAGE_MULTI_VIEW_PREFIX}.AddViewer`; +export const REMOVE_VIEWER = `${IMAGE_MULTI_VIEW_PREFIX}.RemoveViewer`; +export const VIEWER_MOUNTED = `${IMAGE_MULTI_VIEW_PREFIX}.viewMounted`; +export const VIEWER_UNMOUNTED = `${IMAGE_MULTI_VIEW_PREFIX}.viewUnmounted`; +export const VIEWER_SCROLL = `${IMAGE_MULTI_VIEW_PREFIX}.viewScroll`; +export const BOTTOM_UI_COMPONENT = `${IMAGE_MULTI_VIEW_PREFIX}.bottomUIComponent`; +export const ADD_VIEWER_ITEMS = `${IMAGE_MULTI_VIEW_PREFIX}.addViewerItems`; +export const REMOVE_VIEWER_ITEMS = `${IMAGE_MULTI_VIEW_PREFIX}.removeViewerItems`; +export const REPLACE_VIEWER_ITEMS = `${IMAGE_MULTI_VIEW_PREFIX}.replaceViewerItems`; +export const CHANGE_VIEWER_LAYOUT = `${IMAGE_MULTI_VIEW_PREFIX}.changeViewerLayout`; +export const UPDATE_VIEWER_CUSTOM_DATA = `${IMAGE_MULTI_VIEW_PREFIX}.updateViewerCustomData`; +export const ADD_TO_AUTO_RECEIVER = `${IMAGE_MULTI_VIEW_PREFIX}.addToAutoReceiver`; + + +// ---------------------------------------- +// actions use by DrawLayerCntlr +// ---------------------------------------- +export const CREATE_DRAWING_LAYER = `${DRAWLAYER_PREFIX}.createDrawLayer`; +export const UPDATE_DRAWING_LAYER = `${DRAWLAYER_PREFIX}.updateDrawLayer`; +export const DESTROY_DRAWING_LAYER = `${DRAWLAYER_PREFIX}.destroyDrawLayer`; +export const CHANGE_VISIBILITY = `${DRAWLAYER_PREFIX}.changeVisibility`; +export const CHANGE_DRAWING_DEF = `${DRAWLAYER_PREFIX}.changeDrawingDef`; +export const ATTACH_LAYER_TO_PLOT = `${DRAWLAYER_PREFIX}.attachLayerToPlot`; +export const DETACH_LAYER_FROM_PLOT = `${DRAWLAYER_PREFIX}.detachLayerFromPlot`; +export const MODIFY_CUSTOM_FIELD = `${DRAWLAYER_PREFIX}.modifyCustomField`; +export const FORCE_DRAW_LAYER_UPDATE = `${DRAWLAYER_PREFIX}.forceDrawLayerUpdate`; + +// PointSelection.js +export const SELECT_POINT = `${DRAWLAYER_PREFIX}.SelectPoint.selectPoint`; +export const EXTRACT_POINT = `${DRAWLAYER_PREFIX}.ExtractPoints.extractPoint`; + +// Distance tool +export const DT_START = `${DRAWLAYER_PREFIX}.DistanceTool.distanceToolStart`; +export const DT_MOVE = `${DRAWLAYER_PREFIX}.DistanceTool.distanceToolMove`; +export const DT_END = `${DRAWLAYER_PREFIX}.DistanceTool.distanceToolEnd`; + +// Extraction Line tool +export const ELT_START = `${DRAWLAYER_PREFIX}.ExtractLineTool.distanceToolStart`; +export const ELT_MOVE = `${DRAWLAYER_PREFIX}.ExtractLineTool.distanceToolMove`; +export const ELT_END = `${DRAWLAYER_PREFIX}.ExtractLineTool.distanceToolEnd`; + +// select +export const SELECT_AREA_START = `${DRAWLAYER_PREFIX}.SelectArea.selectAreaStart`; +export const SELECT_AREA_MOVE = `${DRAWLAYER_PREFIX}.SelectArea.selectAreaMove`; +export const SELECT_AREA_END = `${DRAWLAYER_PREFIX}.SelectArea.selectAreaEnd`; +export const SELECT_MOUSE_LOC = `${DRAWLAYER_PREFIX}.SelectArea.selectMouseLoc`; + +// marker and footprint +export const MARKER_START = `${DRAWLAYER_PREFIX}.MarkerTool.markerStart`; +export const MARKER_MOVE = `${DRAWLAYER_PREFIX}.MarkerTool.markerMove`; +export const MARKER_END = `${DRAWLAYER_PREFIX}.MarkerTool.markerEnd`; +export const MARKER_CREATE = `${DRAWLAYER_PREFIX}.MarkerTool.markerCreate`; +export const FOOTPRINT_CREATE = `${DRAWLAYER_PREFIX}.FootprintTool.footprintCreate`; +export const FOOTPRINT_START = `${DRAWLAYER_PREFIX}.FootprintTool.footprintStart`; +export const FOOTPRINT_END = `${DRAWLAYER_PREFIX}.FootprintTool.footprintEnd`; +export const FOOTPRINT_MOVE = `${DRAWLAYER_PREFIX}.FootprintTool.footprintMove`; + +// region +export const REGION_CREATE_LAYER = `${DRAWLAYER_PREFIX}.RegionPlot.createLayer`; +export const REGION_DELETE_LAYER = `${DRAWLAYER_PREFIX}.RegionPlot.deleteLayer`; +export const REGION_ADD_ENTRY = `${DRAWLAYER_PREFIX}.RegionPlot.addRegion`; +export const REGION_REMOVE_ENTRY = `${DRAWLAYER_PREFIX}.RegionPlot.removeRegion`; +export const REGION_SELECT = `${DRAWLAYER_PREFIX}.RegionPlot.selectRegion`; + +export const IMAGELINEBASEDFP_CREATE = `${DRAWLAYER_PREFIX}.ImageLineBasedFP.imagelineBasedFPCreate`; + + +/** @typedef GroupingScope + * enum can be one of + * @prop STANDARD + * @prop SUBGROUP + * @prop GROUP + * @type {Enum} + */ + +/** @type GroupingScope */ +export const GroupingScope = new Enum(['STANDARD', 'SUBGROUP', 'SINGLE']); /** @typedef ExpandType * enum can be one of @@ -27,6 +231,7 @@ import Enum from 'enum'; * @prop SINGLE * @type {Enum} */ + /** @type ExpandType */ export const ExpandType = new Enum(['COLLAPSE', 'GRID', 'SINGLE']); @@ -39,6 +244,7 @@ export const ExpandType = new Enum(['COLLAPSE', 'GRID', 'SINGLE']); * @prop PixelCenter * @type {Enum} */ + /** @type WcsMatchType */ export const WcsMatchType = new Enum(['Standard', 'Target', 'Pixel', 'PixelCenter']); @@ -52,13 +258,10 @@ export const WcsMatchType = new Enum(['Standard', 'Target', 'Pixel', 'PixelCente * @public * @global */ + /** @type ActionScope */ export const ActionScope = new Enum(['GROUP', 'SINGLE', 'LIST']); -// ─── From MultiViewCntlr.js ────────────────────────────────────────────────── - -export const IMAGE = 'image'; -export const EXPANDED_MODE_RESERVED = 'EXPANDED_MODE_RESERVED'; /** * @typedef NewPlotMode @@ -68,5 +271,72 @@ export const EXPANDED_MODE_RESERVED = 'EXPANDED_MODE_RESERVED'; * @prop none * @type {Enum} */ + /** @type NewPlotMode */ export const NewPlotMode = new Enum(['create_replace', 'replace_only', 'none']); + + +// ---------------------------------------- +// Enums use by Zoom functions +// ---------------------------------------- + +/** + * @typedef ZoomType + * @summary zoom type + * @description can be 'STANDARD', 'LEVEL', 'FULL_SCREEN', 'TO_WIDTH_HEIGHT', 'TO_WIDTH', 'TO_HEIGHT', 'ARCSEC_PER_SCREEN_PIX' + * @prop STANDARD + * @prop LEVEL + * @prop FULL_SCREEN + * @prop TO_WIDTH_HEIGHT + * @prop TO_WIDTH + * @prop TO_HEIGHT + * @prop ARCSEC_PER_SCREEN_PIX + * @type {Enum} + * @public + * @global + */ + + +/** @type ZoomType */ +export const ZoomType = new Enum([ + 'STANDARD', // use normal zoom, zoom to given zoom level or 1x if not specified + 'LEVEL', // use normal zoom, zoom to given zoom level or 1x if not specified + 'FULL_SCREEN', // requires width & height specified. deprecated, same as TO_WIDTH_HEIGHT + 'TO_WIDTH_HEIGHT', // requires width & height specified + 'TO_WIDTH', // requires width + 'TO_HEIGHT', // requires height, not yet implemented + 'ARCSEC_PER_SCREEN_PIX' // arcsec +]); + +/** + * @typedef UserZoomTypes + * can be 'UP','DOWN', 'FIT', 'FILL', 'ONE', 'LEVEL', 'WCS_MATCH_PREV' + * @prop UP, + * @prop DOWN, + * @prop FIT, + * @prop FILL, + * @prop ONE, + * @prop LEVEL, + * @prop WCS_MATCH_PREV, + * @type {Enum} + * @public + * @global + */ + +/** @type UserZoomTypes */ +export const UserZoomTypes = new Enum(['UP', 'DOWN', 'FIT', 'FILL', 'ONE', 'LEVEL', 'WCS_MATCH_PREV'], {ignoreCase: true}); // _- Distance tool + + +/** + * @typedef FullType + * enum can be one of + * @prop ONLY_WIDTH + * @prop WIDTH_HEIGHT + * @prop ONLY_HEIGHT + * @prop {Function} has + * @type {Enum} + */ + + +/** @type FullType */ +export const FullType = new Enum(['ONLY_WIDTH', 'WIDTH_HEIGHT', 'ONLY_HEIGHT']); \ No newline at end of file diff --git a/src/firefly/js/visualize/VisMouseSync.js b/src/firefly/js/visualize/VisMouseSync.js index 91e8cf372c..893b5a381a 100644 --- a/src/firefly/js/visualize/VisMouseSync.js +++ b/src/firefly/js/visualize/VisMouseSync.js @@ -6,8 +6,7 @@ */ import Enum from 'enum'; -import {primePlot} from './PlotViewUtil.js'; -import {visRoot} from './ImagePlotCntlr.js'; +import {currentP} from './PlotViewUtil.js'; import {CysConverter} from './CsysConverter.js'; import {isHiPS} from './WebPlot.js'; import {getHealpixPixel} from './HiPSUtil'; @@ -115,7 +114,7 @@ export function fireMouseReadoutChange({readoutType= STANDARD_READOUT, plotId, r export function makeMouseStatePayload(plotId,mouseState,screenPt,screenX,screenY,eventType='', {shiftDown,controlDown,metaDown}= {}) { const payload={mouseState,screenPt,screenX,screenY, shiftDown,controlDown,metaDown,eventType}; - const plot= primePlot(visRoot(),plotId); + const {plot}= currentP(plotId); const cc= CysConverter.make(plot); if (!plotId || !plot) return payload; payload.plotId= plotId; diff --git a/src/firefly/js/visualize/VisStoreRoots.js b/src/firefly/js/visualize/VisStoreRoots.js new file mode 100644 index 0000000000..c65ae279a1 --- /dev/null +++ b/src/firefly/js/visualize/VisStoreRoots.js @@ -0,0 +1,33 @@ +import {flux} from '../core/ReduxFlux'; +import {DRAWING_LAYER_KEY, IMAGE_PLOT_KEY} from './VisConst'; + +/** + * @returns {VisRoot} + * + * @public + * @function visRoot + * @memberof firefly.action + * */ +export function visRoot() { + return flux.getState()[IMAGE_PLOT_KEY]; +} + +/** + * return DrawLayerRoot + * @public + * @function dlRoot + * @return {DrawLayerRoot} + */ +export function dlRoot() { + return flux.getState()[DRAWING_LAYER_KEY]; +} + +/** + * Return, from the store, the master array of all the drawing layers on all the plots + * @returns {DrawLayer[]} + * @memberof firefly.action + * @function getDlAry + */ +export function getDlAry() { + return flux.getState()[DRAWING_LAYER_KEY].drawLayerAry ?? []; +} \ No newline at end of file diff --git a/src/firefly/js/visualize/WebPlot.js b/src/firefly/js/visualize/WebPlot.js index bf8478a273..44a9b33a69 100644 --- a/src/firefly/js/visualize/WebPlot.js +++ b/src/firefly/js/visualize/WebPlot.js @@ -1,7 +1,7 @@ /* * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import {ZoomType} from 'firefly/visualize/ZoomType.js'; +import {ZoomType} from './VisConst'; import {isArray, isBoolean, isEmpty, isNumber, isUndefined} from 'lodash'; import {isDefined, memorizeLastCall} from '../util/WebUtil'; import {allBandAry, Band} from './Band'; diff --git a/src/firefly/js/visualize/WebPlotRequest.js b/src/firefly/js/visualize/WebPlotRequest.js index dd110b70c5..8b170dc47b 100644 --- a/src/firefly/js/visualize/WebPlotRequest.js +++ b/src/firefly/js/visualize/WebPlotRequest.js @@ -3,7 +3,7 @@ import {get, isString, isFunction, isPlainObject, isArray, join, omit, pick, isO import Enum from 'enum'; import {ServerRequest} from '../data/ServerRequest.js'; import {RequestType} from './RequestType.js'; -import {ZoomType} from './ZoomType.js'; +import {ZoomType} from './VisConst'; import {RangeValues} from './RangeValues.js'; import {PlotAttribute} from './PlotAttribute.js'; import CoordinateSys from 'firefly/visualize/CoordSys.js'; diff --git a/src/firefly/js/visualize/ZoomType.js b/src/firefly/js/visualize/ZoomType.js deleted file mode 100644 index 8f0abaef2a..0000000000 --- a/src/firefly/js/visualize/ZoomType.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt - */ -/** - * User: roby - * Date: 7/7/11 - * Time: 12:46 PM - */ - -import Enum from 'enum'; - -/** - * @typedef ZoomType - * @summary zoom type - * @description can be 'STANDARD', 'LEVEL', 'FULL_SCREEN', 'TO_WIDTH_HEIGHT', 'TO_WIDTH', 'TO_HEIGHT', 'ARCSEC_PER_SCREEN_PIX' - * @prop STANDARD - * @prop LEVEL - * @prop FULL_SCREEN - * @prop TO_WIDTH_HEIGHT - * @prop TO_WIDTH - * @prop TO_HEIGHT - * @prop ARCSEC_PER_SCREEN_PIX - * @type {Enum} - * @public - * @global - */ -export const ZoomType= new Enum([ - 'STANDARD', // use normal zoom, zoom to given zoom level or 1x if not specified - 'LEVEL', // use normal zoom, zoom to given zoom level or 1x if not specified - 'FULL_SCREEN', // requires width & height specified. deprecated, same as TO_WIDTH_HEIGHT - 'TO_WIDTH_HEIGHT', // requires width & height specified - 'TO_WIDTH', // requires width - 'TO_HEIGHT', // requires height, not yet implemented - 'ARCSEC_PER_SCREEN_PIX' // arcsec - ]); diff --git a/src/firefly/js/visualize/ZoomUtil.js b/src/firefly/js/visualize/ZoomUtil.js index 00054d1bee..3a2bb17023 100644 --- a/src/firefly/js/visualize/ZoomUtil.js +++ b/src/firefly/js/visualize/ZoomUtil.js @@ -1,25 +1,15 @@ /* * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import Enum from 'enum'; import {sprintf} from '../externalSource/sprintf'; import {logger} from '../util/Logger.js'; -import {getPixScaleArcSec, isHiPS, isHiPSAitoff, isImage} from './WebPlot.js'; import {PlotAttribute} from './PlotAttribute.js'; import {getFoV, primePlot} from './PlotViewUtil.js'; +import {FullType, UserZoomTypes} from './VisConst'; import {convertAngle} from './VisUtil.js'; +import {getPixScaleArcSec, isHiPS, isHiPSAitoff, isImage} from './WebPlot.js'; -/** - * @typedef FullType - * enum can be one of - * @prop ONLY_WIDTH - * @prop WIDTH_HEIGHT - * @prop ONLY_HEIGHT - * @prop {Function} has - * @type {Enum} - */ -export const FullType = new Enum(['ONLY_WIDTH', 'WIDTH_HEIGHT', 'ONLY_HEIGHT']); /** * This is the master list of zoom levels for Firefly image displays. @@ -62,23 +52,6 @@ export const hipsLevelsReversed= [...hipsLevels].reverse(); const IMAGE_ZOOM_MAX= imageLevels[imageLevels.length-1]; const HIPS_ZOOM_MAX= hipsLevels[hipsLevels.length-1]; -/** - * @typedef UserZoomTypes - * can be 'UP','DOWN', 'FIT', 'FILL', 'ONE', 'LEVEL', 'WCS_MATCH_PREV' - * @prop UP, - * @prop DOWN, - * @prop FIT, - * @prop FILL, - * @prop ONE, - * @prop LEVEL, - * @prop WCS_MATCH_PREV, - * @type {Enum} - * @public - * @global - */ -/** @type UserZoomTypes */ -export const UserZoomTypes= new Enum(['UP','DOWN', 'FIT', 'FILL', 'ONE', 'LEVEL', 'WCS_MATCH_PREV'], { ignoreCase: true }); - /** * * @param {WebPlot} plot diff --git a/src/firefly/js/visualize/__tests__/ImagePlotCntlr-test.js b/src/firefly/js/visualize/__tests__/ImagePlotCntlr-test.js index a835c802b8..f254110d4a 100644 --- a/src/firefly/js/visualize/__tests__/ImagePlotCntlr-test.js +++ b/src/firefly/js/visualize/__tests__/ImagePlotCntlr-test.js @@ -1,7 +1,8 @@ import {flux} from '../../core/ReduxFlux.js'; import {makePlotView} from '../reducer/PlotView.js'; import {WebPlotRequest} from '../WebPlotRequest.js'; -import ImagePlotCntlr, {visRoot} from '../ImagePlotCntlr'; +import {EXPANDED_AUTO_PLAY} from '../VisConst'; +import {visRoot} from '../VisStoreRoots'; @@ -41,7 +42,7 @@ describe('Test ImagePlotCntlr', () => { test('visroot auto play on', () => { const before= visRoot().singleAutoPlay; flux.getRedux().dispatch( { - type:ImagePlotCntlr.EXPANDED_AUTO_PLAY, + type:EXPANDED_AUTO_PLAY, payload: {autoPlayOn:true} }); expect(before).toEqual(false); diff --git a/src/firefly/js/visualize/draw/CanvasWrapper.jsx b/src/firefly/js/visualize/draw/CanvasWrapper.jsx index 78ed6f78e6..11c73105aa 100644 --- a/src/firefly/js/visualize/draw/CanvasWrapper.jsx +++ b/src/firefly/js/visualize/draw/CanvasWrapper.jsx @@ -6,7 +6,7 @@ import React, {Component} from 'react'; import PropTypes from 'prop-types'; import {Drawer} from './Drawer.js'; import {makeDrawingDef} from './DrawingDef.js'; -import {CANVAS_DL_ID_START} from '../PlotViewUtil.js'; +import {CANVAS_DL_ID_START} from '../VisConst'; function updateDrawer(drawer,plot, width, height, drawLayer,force=false) { diff --git a/src/firefly/js/visualize/draw/DrawLayer.js b/src/firefly/js/visualize/draw/DrawLayer.js index 315a2299ac..620c8486f6 100644 --- a/src/firefly/js/visualize/draw/DrawLayer.js +++ b/src/firefly/js/visualize/draw/DrawLayer.js @@ -3,7 +3,7 @@ */ import {makeDrawingDef} from './DrawingDef.js'; -import {GroupingScope} from '../DrawLayerCntlr.js'; +import {GroupingScope} from '../VisConst'; export default {makeDrawLayer}; diff --git a/src/firefly/js/visualize/draw/DrawerComponent.jsx b/src/firefly/js/visualize/draw/DrawerComponent.jsx index f36f1df6d6..e8d33bb38f 100644 --- a/src/firefly/js/visualize/draw/DrawerComponent.jsx +++ b/src/firefly/js/visualize/draw/DrawerComponent.jsx @@ -4,9 +4,9 @@ import React, {memo,useState,useEffect} from 'react'; import PropTypes from 'prop-types'; +import {dlRoot} from '../VisStoreRoots'; import CanvasWrapper from './CanvasWrapper.jsx'; import {getDrawLayerById} from '../PlotViewUtil.js'; -import {dlRoot} from '../DrawLayerCntlr.js'; import {useStoreConnector} from 'firefly/ui/SimpleComponent.jsx'; diff --git a/src/firefly/js/visualize/draw/ImageLineBasedObj.js b/src/firefly/js/visualize/draw/ImageLineBasedObj.js index 4446d9af7d..6aa15a91a6 100644 --- a/src/firefly/js/visualize/draw/ImageLineBasedObj.js +++ b/src/firefly/js/visualize/draw/ImageLineBasedObj.js @@ -9,8 +9,7 @@ import {makeZeroBasedImagePt, makeFitsImagePt, makeImagePt, makeAnyPt} from '../ import {clone} from '../../util/WebUtil.js'; import {CoordinateSys} from '../CoordSys.js'; import {DrawSymbol} from './DrawSymbol.js'; -import {primePlot} from '../PlotViewUtil.js'; -import {visRoot} from '../ImagePlotCntlr.js'; +import {currentP} from '../PlotViewUtil.js'; const IMGFP_OBJ = 'ImgBasedFPObj'; export const drawMode = new Enum(['data', 'highlight', 'select']); @@ -743,7 +742,7 @@ export class ConnectedObj { const {lineWidth = 1} = drawingDef; const lw = lineWidth+1; - const plot = primePlot(visRoot(), cc.plotId); + const {plot} = currentP(cc.plotId); const polyHighlight = polyAry.reduce((prev, onePoly, idx) => { const newhObj = DrawOp.makeHighlight(onePoly, plot, drawingDef); newhObj.highlight = 1; @@ -772,7 +771,7 @@ export class ConnectedObj { const pointAry = this.basicObjs[POINTOBJS]; const selDrawDef= Object.assign({}, drawingDef, {selectColor:drawingDef.selectedColor}); - const plot = primePlot(visRoot(), cc.plotId); + const {plot} = currentP(cc.plotId); const polySels = polyAry && polyAry.reduce((prev, onePoly) => { const newhObj = DrawOp.makeHighlight(onePoly, plot, selDrawDef); newhObj.highlight = 1; diff --git a/src/firefly/js/visualize/draw/PointDataObj.js b/src/firefly/js/visualize/draw/PointDataObj.js index b4efc02e95..0bf0ffb718 100644 --- a/src/firefly/js/visualize/draw/PointDataObj.js +++ b/src/firefly/js/visualize/draw/PointDataObj.js @@ -14,7 +14,7 @@ import ShapeDataObj, {drawText, translateTo, rotateAround, getPVRotateAngle} fro import {isWithinPolygon, makeShapeHighlightRenderOptions, DELTA, defaultDashline} from './ShapeHighlight.js'; import { handleTextFromRegion } from './ShapeToRegion.js'; import {isNil, isEmpty, has, set, get, cloneDeep} from 'lodash'; -import {defaultRegionSelectColor, defaultRegionSelectStyle} from '../DrawLayerCntlr.js'; +import {defaultRegionSelectColor, defaultRegionSelectStyle} from '../VisConst'; import {DrawSymbol} from './DrawSymbol.js'; diff --git a/src/firefly/js/visualize/draw/ShapeDataObj.js b/src/firefly/js/visualize/draw/ShapeDataObj.js index 6d1dd4bd82..efa51c8a5b 100644 --- a/src/firefly/js/visualize/draw/ShapeDataObj.js +++ b/src/firefly/js/visualize/draw/ShapeDataObj.js @@ -15,8 +15,7 @@ import {toRegion} from './ShapeToRegion.js'; import {getDrawobjArea, isScreenPtInRegion, makeHighlightShapeDataObj} from './ShapeHighlight.js'; import CsysConverter from '../CsysConverter.js'; import {has, isNil, get, set, isEmpty} from 'lodash'; -import {getPlotViewById, getCenterOfProjection, getFoV} from '../PlotViewUtil.js'; -import {visRoot} from '../ImagePlotCntlr.js'; +import {currentP, getCenterOfProjection, getFoV} from '../PlotViewUtil.js'; import {getPixScaleArcSec, getScreenPixScaleArcSec} from '../WebPlot.js'; import {toRadians, toDegrees} from '../VisUtil.js'; import {rateOpacity, maximizeOpacity} from '../../util/Color.js'; @@ -64,7 +63,7 @@ export function makePoint(pt, plot, toType) { } export function flipTextLocAroundY(plot, textLoc) { - const pv = getPlotViewById(visRoot(), plot.plotId); + const {pv} = currentP(plot.plotId); if (pv?.flipY) { const locSet = [TextLocation.CIRCLE_NE, TextLocation.CIRCLE_NW, @@ -87,7 +86,7 @@ export function flipTextLocAroundY(plot, textLoc) { } export function getPVRotateAngle(plot, angle) { - const pv = getPlotViewById(visRoot(), plot.plotId); + const {pv} = currentP(plot.plotId); let angleInRadian = pv.rotation ? convertAngle('deg', 'radian', pv.rotation) : 0.0; if (pv.flipY) { @@ -873,7 +872,7 @@ function drawCircle(drawObj, ctx, plot, drawParams) { */ export function drawText(drawObj, ctx, plot, inPt, drawParams) { if (!inPt) return false; - const pv = getPlotViewById(visRoot(), plot.plotId); + const {pv} = currentP(plot.plotId); if (!pv) return false; const {text, textOffset, renderOptions, rotationAngle, isLonLine, textBaseline= 'top', @@ -1648,7 +1647,7 @@ function makeTextLocationLine(plot, textLoc, fontSize, inPt0, inPt1, tIndex, dra let offset = height * (tIndex + 0.5); const r = -1; - const pv = getPlotViewById(visRoot(), plot.plotId); + const {pv} = currentP(plot.plotId); if ((!pv.flipY && slope >= -Math.PI/2 && slope < Math.PI/2 && !pv.flipY) || (pv.flipY && (slope < -Math.PI/2 || slope >= Math.PI/2 ))) { // quadrant 1 & 4 for no flipY diff --git a/src/firefly/js/visualize/draw/ShapeHighlight.js b/src/firefly/js/visualize/draw/ShapeHighlight.js index 27de30f432..d20fe972a0 100644 --- a/src/firefly/js/visualize/draw/ShapeHighlight.js +++ b/src/firefly/js/visualize/draw/ShapeHighlight.js @@ -6,7 +6,7 @@ import {computeScreenDistance, convertAngle} from '../VisUtil.js'; import ShapeDataObj, {rectOnImage, lengthToImagePixel, widthAfterRotation, heightAfterRotation } from './ShapeDataObj.js'; import {makeScreenPt, makeImagePt} from '../Point.js'; import {get, isNil, set, has, cloneDeep} from 'lodash'; -import {defaultRegionSelectColor, defaultRegionSelectStyle, RegionSelColor, RegionSelStyle} from '../DrawLayerCntlr.js'; +import {defaultRegionSelectColor, defaultRegionSelectStyle, RegionSelColor, RegionSelStyle} from '../VisConst'; import {TextLocation} from './DrawingDef.js'; import {SimplePt} from '../Point.js'; diff --git a/src/firefly/js/visualize/iv/EventLayer.jsx b/src/firefly/js/visualize/iv/EventLayer.jsx index 6fafdd2703..c34dcc9c53 100644 --- a/src/firefly/js/visualize/iv/EventLayer.jsx +++ b/src/firefly/js/visualize/iv/EventLayer.jsx @@ -5,8 +5,7 @@ import React, {memo, useRef, useEffect} from 'react'; import {func,string,object} from 'prop-types'; import {checkProps} from '../../ui/SimpleComponent'; import {CCUtil} from '../CsysConverter'; -import {visRoot} from '../ImagePlotCntlr'; -import {primePlot} from '../PlotViewUtil'; +import {currentP} from '../PlotViewUtil'; import {makeScreenPt} from '../Point.js'; import {MouseState} from '../VisMouseSync.js'; import {Matrix} from '../../externalSource/transformation-matrix-js/matrix'; @@ -37,7 +36,7 @@ function firePinchEvent(inEvent, transform, plotId, originalCenterPt, mouseState const ev= inEvent.nativeEvent ?? inEvent; ev.preventDefault(); ev.stopPropagation(); - const plot= primePlot(visRoot(), plotId); + const {plot}= currentP(plotId); const spt= CCUtil.getScreenCoords(plot,originalCenterPt); eventCallback(plotId,mouseState,spt,spt.x,spt.y,ev); } @@ -89,7 +88,7 @@ function makeTouchCenterPt(ev,transform,plotId) { const offsetX= x - rect.left; const offsetY= y - rect.top; const spt= createScreenPt(transform,offsetX,offsetY); - const plot= primePlot(visRoot(), plotId); + const {plot}= currentP(plotId); return {touchPt0, touchPt1, centerPt: isHiPS(plot) ? CCUtil.getWorldCoords(plot,spt) : CCUtil.getImageCoords(plot,spt) }; diff --git a/src/firefly/js/visualize/iv/ExpandedTools.jsx b/src/firefly/js/visualize/iv/ExpandedTools.jsx index dcdcdcfd47..f0bbb53d6f 100644 --- a/src/firefly/js/visualize/iv/ExpandedTools.jsx +++ b/src/firefly/js/visualize/iv/ExpandedTools.jsx @@ -8,18 +8,16 @@ import PropTypes from 'prop-types'; import {Button, Checkbox, IconButton, Sheet, Stack, Switch, Tooltip, Typography} from '@mui/joy'; import {useStoreConnector} from '../../ui/SimpleComponent.jsx'; import {ToolbarHorizontalSeparator} from '../../ui/ToolbarButton.jsx'; -import { - ExpandType, dispatchChangeExpandedMode, dispatchExpandedAutoPlay, visRoot, -} from '../ImagePlotCntlr.js'; +import {EXPANDED_MODE_RESERVED, ExpandType} from '../VisConst'; +import {visRoot} from '../VisStoreRoots'; import {HIDDEN} from '../ImViewFilterDisplay'; -import {primePlot, getActivePlotView} from '../PlotViewUtil.js'; +import {primePlot, currentP} from '../PlotViewUtil.js'; import {CloseButton} from '../../ui/CloseButton.jsx'; import {DisplayTypeButtonGroup} from '../ui/Buttons.jsx'; import {ViewOptionsButton} from '../ui/ExpandedOptionsPopup.jsx'; -import {dispatchChangeActivePlotView} from '../ImagePlotCntlr.js'; +import {dispatchChangeActivePlotView, dispatchChangeExpandedMode, dispatchExpandedAutoPlay} from '../ImagePlotDispatch'; import { - getMultiViewRoot, getExpandedViewerItemIds, getViewer, EXPANDED_MODE_RESERVED, dispatchViewerScroll, - getViewerItemIds, + getMultiViewRoot, getExpandedViewerItemIds, getViewer, dispatchViewerScroll, getViewerItemIds, } from '../MultiViewCntlr.js'; import {VisMiniToolbar} from 'firefly/visualize/ui/VisMiniToolbar.jsx'; @@ -50,7 +48,7 @@ function createOptions(expandedMode, singleAutoPlay, plotIdAry) { function getState() { const {expandedMode,activePlotId, singleAutoPlay, plotViewAry}= visRoot(); - return {expandedMode,activePlotId, singleAutoPlay, plotViewAry, pv:getActivePlotView(visRoot())}; + return {expandedMode,activePlotId, singleAutoPlay, plotViewAry, pv:currentP().pv}; } export function ExpandedTools({closeFunc}) { diff --git a/src/firefly/js/visualize/iv/HiPSTileCache.js b/src/firefly/js/visualize/iv/HiPSTileCache.js index 447d0c87e0..f0c4bd4ce4 100644 --- a/src/firefly/js/visualize/iv/HiPSTileCache.js +++ b/src/firefly/js/visualize/iv/HiPSTileCache.js @@ -2,7 +2,7 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ import {isString} from 'lodash'; -import {visRoot} from '../ImagePlotCntlr.js'; +import {visRoot} from '../VisStoreRoots'; import {getPlotViewAry, primePlot} from '../PlotViewUtil.js'; import {NO_COLOR_TABLE} from '../rawData/ColorTable'; import {isHiPS} from '../WebPlot.js'; diff --git a/src/firefly/js/visualize/iv/ImageExpandedMode.jsx b/src/firefly/js/visualize/iv/ImageExpandedMode.jsx index 7b5ca1af20..38ea704820 100644 --- a/src/firefly/js/visualize/iv/ImageExpandedMode.jsx +++ b/src/firefly/js/visualize/iv/ImageExpandedMode.jsx @@ -3,10 +3,10 @@ */ import React, {memo, useEffect} from 'react'; import PropTypes from 'prop-types'; -import {visRoot, dispatchChangeExpandedMode, ExpandType, dispatchChangeActivePlotView} from '../ImagePlotCntlr.js'; -import { - getMultiViewRoot, getViewer, getExpandedViewerItemIds, EXPANDED_MODE_RESERVED, DEFAULT_FITS_VIEWER_ID -} from '../MultiViewCntlr.js'; +import {dispatchChangeActivePlotView, dispatchChangeExpandedMode} from '../ImagePlotDispatch'; +import { getMultiViewRoot, getViewer, getExpandedViewerItemIds } from '../MultiViewCntlr.js'; +import {DEFAULT_FITS_VIEWER_ID, EXPANDED_MODE_RESERVED, ExpandType} from '../VisConst'; +import {visRoot} from '../VisStoreRoots'; import {SmallLegend} from '../ui/SmallLegend'; import {ExpandedTools} from './ExpandedTools.jsx'; import {MultiImageViewerView} from '../ui/MultiImageViewerView.jsx'; diff --git a/src/firefly/js/visualize/iv/ImageRender.jsx b/src/firefly/js/visualize/iv/ImageRender.jsx index c482dc2d8a..ae1fd8f055 100644 --- a/src/firefly/js/visualize/iv/ImageRender.jsx +++ b/src/firefly/js/visualize/iv/ImageRender.jsx @@ -8,7 +8,7 @@ import {SimpleCanvas} from '../draw/SimpleCanvas.jsx'; import {initImageDrawer} from './ImageTileDrawer.js'; import {createHiPSDrawer} from './HiPSTileDrawer.js'; import {isImage} from '../WebPlot.js'; -import {CANVAS_IMAGE_ID_START} from '../PlotViewUtil.js'; +import {CANVAS_IMAGE_ID_START} from '../VisConst'; import {primePlot} from '../PlotViewUtil'; const BG_IMAGE= 'image-working-background-24x24.png'; diff --git a/src/firefly/js/visualize/iv/ImageViewer.jsx b/src/firefly/js/visualize/iv/ImageViewer.jsx index 814ab3f888..646a46d7aa 100644 --- a/src/firefly/js/visualize/iv/ImageViewer.jsx +++ b/src/firefly/js/visualize/iv/ImageViewer.jsx @@ -9,13 +9,13 @@ import {omit} from 'lodash'; import shallowequal from 'shallowequal'; import {getPlotViewById, getAllDrawLayersForPlot, getPlotViewProxyById} from '../PlotViewUtil.js'; import {ImageViewerView, getImageViewerDecorateSx} from './ImageViewerDecorate.jsx'; -import {visRoot, ExpandType} from '../ImagePlotCntlr.js'; +import {ExpandType} from '../VisConst'; +import {dlRoot, visRoot} from '../VisStoreRoots'; import {extensionRoot} from '../../core/ExternalAccessCntlr.js'; import {MouseState, addImageMouseListener, lastMouseCtx} from '../VisMouseSync.js'; import {getPlotUIExtensionList} from '../../core/ExternalAccessUtils.js'; import {getWorkingTask} from '../../core/AppDataCntlr.js'; import {useStoreConnector} from '../../ui/SimpleComponent'; -import {dlRoot} from '../DrawLayerCntlr'; import {ImageViewStatusPanel} from './ImageViewerStatus'; diff --git a/src/firefly/js/visualize/iv/ImageViewerDecorate.jsx b/src/firefly/js/visualize/iv/ImageViewerDecorate.jsx index 494fe5989a..097fb60d1a 100644 --- a/src/firefly/js/visualize/iv/ImageViewerDecorate.jsx +++ b/src/firefly/js/visualize/iv/ImageViewerDecorate.jsx @@ -12,9 +12,10 @@ import {getSearchActions} from '../../core/AppDataCntlr.js'; import HpxCatalog from '../../drawingLayers/hpx/HpxCatalog'; import {getTblById} from '../../tables/TableUtil'; import {wrapResizeMonitor} from '../../ui/ResizeMonitor'; -import {EXPANDED_MODE_RESERVED, getMultiViewRoot, getViewer, GRID, IMAGE} from '../MultiViewCntlr.js'; +import {getMultiViewRoot, getViewer} from '../MultiViewCntlr.js'; import {getPlotGroupById} from '../PlotGroup.js'; -import {ExpandType, dispatchChangeActivePlotView, MOUSE_CLICK_REASON} from '../ImagePlotCntlr.js'; +import {dispatchChangeActivePlotView} from '../ImagePlotDispatch'; +import {EXPANDED_MODE_RESERVED, ExpandType, GRID, IMAGE, MOUSE_CLICK_REASON} from '../VisConst'; import {ExpandButton} from '../ui/Buttons.jsx'; import {VisCtxToolbarView, ctxToolbarBG} from '../ui/VisCtxToolbarView'; import {PvControlsAndFeedback} from '../ui/PvControlsAndFeedback.jsx'; diff --git a/src/firefly/js/visualize/iv/PlotTitle.jsx b/src/firefly/js/visualize/iv/PlotTitle.jsx index a98d87f842..206a0e8364 100644 --- a/src/firefly/js/visualize/iv/PlotTitle.jsx +++ b/src/firefly/js/visualize/iv/PlotTitle.jsx @@ -8,12 +8,11 @@ import PropTypes from 'prop-types'; import {hasWorkingTask} from '../../core/AppDataCntlr'; import {sprintf} from '../../externalSource/sprintf'; import {useStoreConnector} from '../../ui/SimpleComponent.jsx'; -import {visRoot} from '../ImagePlotCntlr'; import {HALF, QUARTER} from '../rawData/RawDataCommon.js'; import {getDataCompress} from '../rawData/RawDataOps.js'; import {ctxToolbarBG} from '../ui/VisCtxToolbarView.jsx'; import {getZoomDesc} from '../ZoomUtil.js'; -import {primePlot} from '../PlotViewUtil.js'; +import {currentP, primePlot} from '../PlotViewUtil.js'; import {isImage} from '../WebPlot.js'; import {hasWCSProjection, pvEqualExScroll} from '../PlotViewUtil'; @@ -21,7 +20,7 @@ export const PlotTitle= memo(({plotView:pv, brief}) => { const {dataCompress,working}= useStoreConnector(() => ( { working: hasWorkingTask(pv?.plotId), - dataCompress: getDataCompress(primePlot(visRoot(), pv.plotId)?.plotImageId) + dataCompress: getDataCompress(currentP(pv.plotId).plot?.plotImageId) } )); const plot= primePlot(pv); diff --git a/src/firefly/js/visualize/rawData/RawDataOps.js b/src/firefly/js/visualize/rawData/RawDataOps.js index ed9faded13..98da8667d8 100644 --- a/src/firefly/js/visualize/rawData/RawDataOps.js +++ b/src/firefly/js/visualize/rawData/RawDataOps.js @@ -4,12 +4,12 @@ import BrowserInfo from '../../util/BrowserInfo'; import {Band} from '../Band.js'; import {PlotAttribute} from '../PlotAttribute'; import { - findPlot, getOverlayById, getPlotViewById, hasLocalStretchByteData, isThreeColor, primePlot + currentP, findPlot, getOverlayById, getPlotViewById, hasLocalStretchByteData, isThreeColor, primePlot } from '../PlotViewUtil.js'; import {MEG} from '../../util/WebUtil.js'; -import ImagePlotCntlr, { - dispatchAttributeChange, dispatchMarkOutOfMemory, dispatchRequestLocalData, visRoot -} from '../ImagePlotCntlr.js'; +import {BYTE_DATA_REFRESH, PLOT_IMAGE_FAIL} from '../VisConst'; +import {dispatchAttributeChange, dispatchMarkOutOfMemory, dispatchRequestLocalData} from '../ImagePlotDispatch'; +import {visRoot} from '../VisStoreRoots'; import {PlotState} from '../PlotState.js'; import {getNextWorkerKey, isWorkerOutOfMemory, postToWorker} from '../../threadWorker/WorkerAccess.js'; import { @@ -110,7 +110,7 @@ export function queueChangeLocalRawDataColor(params) { } else { p.then( () => { - if (nextColorChangeParams.has(plotImageId) && getPlotViewById(visRoot(),plotId)) { + if (nextColorChangeParams.has(plotImageId) && currentP(plotId).pv) { const {onComplete, ...nextChangeParams}= nextColorChangeParams.get(plotImageId); nextColorChangeParams.delete(plotImageId); changeLocalRawDataColor(nextChangeParams) @@ -338,18 +338,18 @@ export async function loadInitialStretchData(pv, plot, dispatcher) { if (plotInvalid()) return; if (success) { - dispatcher({ type: ImagePlotCntlr.BYTE_DATA_REFRESH, payload:{plotId, imageOverlayId, plotImageId}}); + dispatcher({ type: BYTE_DATA_REFRESH, payload:{plotId, imageOverlayId, plotImageId}}); } else { if (fatal && !silentAbort) { Logger('RawDataOps').warn(`dispatch to the plot failed on BYTE_DATA_REFRESH: ${dataCompress}, status: ${status}`); if (status===404) { Logger('RawDataOps').warn('it appears that the getTile called failed, this might be the server calls are not sticky, or server is out of memory'); - dispatcher({ type: ImagePlotCntlr.PLOT_IMAGE_FAIL, + dispatcher({ type: PLOT_IMAGE_FAIL, payload:{plotId, description:'Failed: server configuration error' }}); } else { - dispatcher({ type: ImagePlotCntlr.PLOT_IMAGE_FAIL, + dispatcher({ type: PLOT_IMAGE_FAIL, payload:{plotId, description:'Failed: Could not retrieve image render data' }}); } } @@ -357,7 +357,7 @@ export async function loadInitialStretchData(pv, plot, dispatcher) { else { Logger('RawDataOps').warn(`non fatal, dispatch the the plot failed on BYTE_DATA_REFRESH: ${dataCompress}`); if (!silentAbort) { - dispatcher({ type: ImagePlotCntlr.PLOT_IMAGE_FAIL, + dispatcher({ type: PLOT_IMAGE_FAIL, payload:{plotId, description:'Failed: Could not retrieve image render data' }}); } } @@ -395,7 +395,7 @@ export async function updateStretchDataAfterZoom(plotId,dispatcher) { if (currentRunningZoomImageId.get(plotImageId).reqId!==reqId) return; //if superseding call came in then return const {success,fatal}= await loadStandardStretchData(workerKey, plot, { dataCompress:nextDataCompress, backgroundUpdate: true, checkForPlotUpdate: true}); if (success) { - dispatcher({ type: ImagePlotCntlr.BYTE_DATA_REFRESH, payload:{plotId, imageOverlayId:undefined, plotImageId}}); + dispatcher({ type: BYTE_DATA_REFRESH, payload:{plotId, imageOverlayId:undefined, plotImageId}}); } else { handleAfterZoomFail(dispatcher,plotId,fatal,nextDataCompress); @@ -407,7 +407,7 @@ function handleAfterZoomFail(dispatcher, plotId, fatal,nextDataCompress) { let msg; if (fatal) { msg= `requestDataAfterZoom: dispatch the the plot failed on BYTE_DATA_REFRESH: ${nextDataCompress}`; - dispatcher({ type: ImagePlotCntlr.PLOT_IMAGE_FAIL, + dispatcher({ type: PLOT_IMAGE_FAIL, payload:{plotId, description:'Failed: Could not retrieve image render data (requestDataAfterZoom)' }}); } else { diff --git a/src/firefly/js/visualize/reducer/DrawLayerReducer.js b/src/firefly/js/visualize/reducer/DrawLayerReducer.js index 65f4862b72..de1df6f668 100644 --- a/src/firefly/js/visualize/reducer/DrawLayerReducer.js +++ b/src/firefly/js/visualize/reducer/DrawLayerReducer.js @@ -2,15 +2,12 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ - -import {get,difference,union} from 'lodash'; -import {clone} from '../../util/WebUtil.js'; +import {difference,union} from 'lodash'; import {DataTypes} from '../draw/DrawLayer.js'; -import DrawLayerCntlr from '../DrawLayerCntlr.js'; -import ImagePlotCntlr from '../ImagePlotCntlr.js'; - - - +import { + ANY_REPLOT, ATTACH_LAYER_TO_PLOT, CHANGE_CENTER_OF_PROJECTION, CHANGE_DRAWING_DEF, CHANGE_HIPS, CHANGE_VISIBILITY, + DETACH_LAYER_FROM_PLOT, FORCE_DRAW_LAYER_UPDATE, MODIFY_CUSTOM_FIELD +} from '../VisConst'; export default {makeReducer}; @@ -22,38 +19,30 @@ export default {makeReducer}; function makeReducer(factory) { return (drawLayer= {}, action={}) => { if (!action.payload || !action.type) return drawLayer; - switch (action.type) { - case DrawLayerCntlr.CHANGE_VISIBILITY: - return changeVisibility(drawLayer,action,factory); - case DrawLayerCntlr.CHANGE_DRAWING_DEF: - return changeDrawingDef(drawLayer,action,factory); - case DrawLayerCntlr.ATTACH_LAYER_TO_PLOT: - return attachLayerToPlot(drawLayer,action,factory); - case DrawLayerCntlr.DETACH_LAYER_FROM_PLOT: - return detachLayerFromPlot(drawLayer,action,factory); - - case DrawLayerCntlr.FORCE_DRAW_LAYER_UPDATE: - case ImagePlotCntlr.ANY_REPLOT: - case ImagePlotCntlr.CHANGE_HIPS: - case ImagePlotCntlr.CHANGE_CENTER_OF_PROJECTION: - case DrawLayerCntlr.MODIFY_CUSTOM_FIELD: + case CHANGE_VISIBILITY: return changeVisibility(drawLayer,action,factory); + case CHANGE_DRAWING_DEF: return changeDrawingDef(drawLayer,action,factory); + case ATTACH_LAYER_TO_PLOT: return attachLayerToPlot(drawLayer,action,factory); + case DETACH_LAYER_FROM_PLOT: return detachLayerFromPlot(drawLayer,action,factory); + + case FORCE_DRAW_LAYER_UPDATE: + case ANY_REPLOT: + case CHANGE_HIPS: + case CHANGE_CENTER_OF_PROJECTION: + case MODIFY_CUSTOM_FIELD: return updateFromLayer(drawLayer,action,factory); - default: - return handleOtherAction(drawLayer,action,factory); + default: return handleOtherAction(drawLayer,action,factory); } }; } function handleOtherAction(drawLayer,action,factory) { - - if (!drawLayer.actionTypeAry.includes(action.type)) return drawLayer; const changes= factory.getLayerChanges(drawLayer,action); - const newDl= (changes && Object.keys(changes).length) ? Object.assign({},drawLayer,changes): drawLayer; + const newDl= (changes && Object.keys(changes).length) ? {...drawLayer,...changes}: drawLayer; let drawData; if (newDl.hasPerPlotData) { //todo- perPlotData does not have the same optimization as normal, look into this @@ -70,9 +59,9 @@ function handleOtherAction(drawLayer,action,factory) { return newDl; } else if (drawData!==newDl.drawData) { - return Object.assign({},newDl,{drawData}); + return {...newDl,...drawData}; } - else {/**/ + else { return drawLayer; } } @@ -81,7 +70,7 @@ function updateFromLayer(drawLayer,action,factory) { let {plotIdAry}= action.payload; if (!plotIdAry) plotIdAry= [action.payload.plotId]; if (!plotIdAry?.length && drawLayer.hasPerPlotData) plotIdAry= drawLayer.visiblePlotIdAry; - drawLayer= Object.assign({}, drawLayer, factory.getLayerChanges(drawLayer,action)); + drawLayer= {...drawLayer, ...factory.getLayerChanges(drawLayer,action)}; if (drawLayer.hasPerPlotData) { plotIdAry.forEach( (id) => { if (drawLayer.plotIdAry.includes(id)) { @@ -91,13 +80,10 @@ function updateFromLayer(drawLayer,action,factory) { }); } }); - - } else { drawLayer.drawData= getDrawData(factory,drawLayer, action); } - return drawLayer; } @@ -116,11 +102,10 @@ function attachLayerToPlot(drawLayer,action,factory) { const addAry= visible ? inputPlotIdAry.filter( (plotId) => !visiblePlotIdAry.includes(plotId)) : []; - drawLayer= clone(drawLayer, { + drawLayer= {...drawLayer, plotIdAry: union(dlPlotIdAry,inputPlotIdAry), - visiblePlotIdAry: [...visiblePlotIdAry,...addAry] - }); - + visiblePlotIdAry: [...visiblePlotIdAry,...addAry], + }; drawLayer= Object.assign(drawLayer, factory.getLayerChanges(drawLayer,action)); if (drawLayer.hasPerPlotData) { drawLayer.plotIdAry.forEach( (id) => @@ -129,8 +114,6 @@ function attachLayerToPlot(drawLayer,action,factory) { else { drawLayer.drawData= getDrawData(factory,drawLayer, action); } - - return drawLayer; } @@ -141,7 +124,7 @@ function detachLayerFromPlot(drawLayer,action,factory) { const plotIdAry= dlPlotIdAry.filter( (id) => !inputPlotIdAry.includes(id)); visiblePlotIdAry= visiblePlotIdAry.filter( (id) => !inputPlotIdAry.includes(id)); - drawLayer= Object.assign({}, drawLayer, factory.getLayerChanges(drawLayer,action), {plotIdAry, visiblePlotIdAry}); + drawLayer= {...drawLayer, ...factory.getLayerChanges(drawLayer,action), plotIdAry, visiblePlotIdAry}; if (drawLayer.hasPerPlotData) { inputPlotIdAry.forEach( (plotId) => drawLayer.drawData= detachPerPlotData(drawLayer.drawData,plotId)); @@ -182,8 +165,7 @@ function changeVisibility(drawLayer,action,factory) { if (visible) { visiblePlotIdAry= union(drawLayer.visiblePlotIdAry,plotIdAry); - drawLayer= Object.assign({}, drawLayer, {visiblePlotIdAry}, - factory.getLayerChanges(drawLayer,action)); + drawLayer= {...drawLayer, visiblePlotIdAry, ...factory.getLayerChanges(drawLayer,action)}; if (drawLayer.hasPerPlotData) { plotIdAry.forEach( (id) => drawLayer.drawData= getDrawData(factory,drawLayer, action, id)); @@ -192,7 +174,7 @@ function changeVisibility(drawLayer,action,factory) { } else { visiblePlotIdAry= difference(drawLayer.visiblePlotIdAry,plotIdAry); - return Object.assign({}, drawLayer, {visiblePlotIdAry}); + return {...drawLayer, visiblePlotIdAry}; } } @@ -200,7 +182,7 @@ function changeVisibility(drawLayer,action,factory) { function changeDrawingDef(drawLayer,action,factory) { const {drawingDef} = action.payload; - return Object.assign({}, drawLayer, {drawingDef}, factory.getLayerChanges(drawLayer,action)); + return {...drawLayer, drawingDef, ...factory.getLayerChanges(drawLayer,action)}; } const DATA= DataTypes.DATA; @@ -219,12 +201,12 @@ function getDrawData(factory, drawLayer, action, plotId= null) { if (!factory.hasGetDrawData(drawLayer)) return drawLayer.drawData; const {drawData= {}}= drawLayer; const pId= plotId; - const newDD= Object.assign({},drawData); + const newDD= {...drawData}; if (!newDD.data) newDD.data={}; if (plotId) { - newDD.data[plotId]= factory.getDrawData(DATA, pId, drawLayer, action, get(drawData,`data.${plotId}`)); + newDD.data[plotId]= factory.getDrawData(DATA, pId, drawLayer, action, drawData?.[`data.${plotId}`]); } else { newDD.data= factory.getDrawData(DATA, pId, drawLayer, action, drawData.data); @@ -235,7 +217,7 @@ function getDrawData(factory, drawLayer, action, plotId= null) { if (!newDD.highlightData) newDD.highlightData={}; if (plotId) { newDD.highlightData[plotId]= factory.getDrawData(HIGHLIGHT_DATA, pId, drawLayer, action, - get(drawData,`highlightData.${plotId}`)); + drawData?.[`highlightData.${plotId}`]); } else { newDD.highlightData= factory.getDrawData(HIGHLIGHT_DATA, pId, drawLayer, action,drawData.highlightData); @@ -269,4 +251,3 @@ function getDrawData(factory, drawLayer, action, plotId= null) { return drawLayer.drawData; } } - diff --git a/src/firefly/js/visualize/reducer/HandlePlotAdmin.js b/src/firefly/js/visualize/reducer/HandlePlotAdmin.js index 199740986c..166f548a4b 100644 --- a/src/firefly/js/visualize/reducer/HandlePlotAdmin.js +++ b/src/firefly/js/visualize/reducer/HandlePlotAdmin.js @@ -2,33 +2,32 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import Cntlr, {ExpandType} from '../ImagePlotCntlr.js'; +import {ExpandType} from '../VisConst'; +import { + API_TOOLS_VIEW, CHANGE_ACTIVE_PLOT_VIEW, CHANGE_EXPANDED_MODE, CHANGE_MOUSE_READOUT_MODE, + CHANGE_POINT_SELECTION, CHANGE_TABLE_AUTO_SCROLL, DELETE_PLOT_VIEW, EXPANDED_AUTO_PLAY, USE_TABLE_AUTO_SCROLL, + WCS_MATCH +} from '../VisConst'; import {getPlotViewById, isImageExpanded} from '../PlotViewUtil.js'; export function reducer(state, action) { switch (action.type) { - case Cntlr.API_TOOLS_VIEW: - return {...state,apiToolsView:action.payload.apiToolsView}; - case Cntlr.CHANGE_ACTIVE_PLOT_VIEW: - return changeActivePlotView(state,action); - case Cntlr.CHANGE_EXPANDED_MODE: - return changeExpandedMode(state,action); - case Cntlr.CHANGE_MOUSE_READOUT_MODE: - return changeMouseReadout(state, action); - case Cntlr.CHANGE_POINT_SELECTION: - return changePointSelection(state,action); - case Cntlr.CHANGE_TABLE_AUTO_SCROLL: + case API_TOOLS_VIEW: return {...state,apiToolsView:action.payload.apiToolsView}; + case CHANGE_ACTIVE_PLOT_VIEW: return changeActivePlotView(state,action); + case CHANGE_EXPANDED_MODE: return changeExpandedMode(state,action); + case CHANGE_MOUSE_READOUT_MODE: return changeMouseReadout(state, action); + case CHANGE_POINT_SELECTION: return changePointSelection(state,action); + case CHANGE_TABLE_AUTO_SCROLL: if (state.autoScrollToHighlightedTableRow===action.payload.enabled) return state; return {...state, autoScrollToHighlightedTableRow:action.payload.enabled}; - case Cntlr.USE_TABLE_AUTO_SCROLL: + case USE_TABLE_AUTO_SCROLL: if (state.useAutoScrollToHighlightedTableRow===action.payload.enabled) return state; return {...state, useAutoScrollToHighlightedTableRow:action.payload.useAutoScroll}; - case Cntlr.DELETE_PLOT_VIEW: - return deletePlotView(state,action); - case Cntlr.WCS_MATCH: + case DELETE_PLOT_VIEW: return deletePlotView(state,action); + case WCS_MATCH: const {wcsMatchCenterWP,wcsMatchType,mpwWcsPrimId}= action.payload; return {...state,wcsMatchCenterWP,wcsMatchType,mpwWcsPrimId}; - case Cntlr.EXPANDED_AUTO_PLAY: + case EXPANDED_AUTO_PLAY: if (state.singleAutoPlay===action.payload.autoPlayOn) return state; return {...state,singleAutoPlay:action.payload.autoPlayOn}; } diff --git a/src/firefly/js/visualize/reducer/HandlePlotChange.js b/src/firefly/js/visualize/reducer/HandlePlotChange.js index 67a2e900c9..230cb8d5dd 100644 --- a/src/firefly/js/visualize/reducer/HandlePlotChange.js +++ b/src/firefly/js/visualize/reducer/HandlePlotChange.js @@ -4,10 +4,14 @@ import {isEmpty, isUndefined, isString, isNumber} from 'lodash'; import {Band} from '../Band.js'; import {getExtType} from '../FitsHeaderUtil.js'; -import Cntlr, {ExpandType, WcsMatchType, ActionScope} from '../ImagePlotCntlr.js'; import { - getRotationAngle, isCsysDirMatching, isEastLeftOfNorth, isPlotNorth -} from '../WebPlotAnalysis'; + ExpandType, WcsMatchType, ActionScope, UserZoomTypes, BYTE_DATA_REFRESH, CHANGE_CENTER_OF_PROJECTION, + CHANGE_HIPS, CHANGE_HIPS_IMAGE_CONVERSION, CHANGE_IMAGE_VISIBILITY, CHANGE_PLOT_ATTRIBUTE, CHANGE_PRIME_PLOT, + CHANGE_SUBHIGHLIGHT_PLOT_VIEW, COLOR_CHANGE, FLIP, MARK_OUT_OF_MEMORY, OVERLAY_COLOR_LOCKING, + OVERLAY_PLOT_CHANGE_ATTRIBUTES, PLOT_PROGRESS_UPDATE, POSITION_LOCKING, PROCESS_SCROLL, RECENTER, + REQUEST_LOCAL_DATA, ROTATE, STRETCH_CHANGE, UPDATE_VIEW_SIZE, ZOOM_HIPS, ZOOM_IMAGE, ZOOM_LOCKING +} from '../VisConst'; +import {getRotationAngle, isCsysDirMatching, isEastLeftOfNorth, isPlotNorth} from '../WebPlotAnalysis'; import {RotateType} from '../PlotState'; import { replacePlotView, replacePrimaryPlot, changePrimePlot, updatePlotViewScrollXY, @@ -15,9 +19,8 @@ import { updateScrollToWcsMatch, updatePlotGroupScrollXY, getNextStaticPlotCount } from './PlotView.js'; import { - WebPlot, clonePlotWithZoom, isHiPS, isImage, - replaceHiPSProjectionUsingProperties, getHiPsTitleFromProperties, DEFAULT_BLANK_HIPS_TITLE, - changeHiPSProjectionCenterAndType, changeHiPSProjectionCenter + WebPlot, clonePlotWithZoom, isHiPS, isImage, replaceHiPSProjectionUsingProperties, getHiPsTitleFromProperties, + DEFAULT_BLANK_HIPS_TITLE, changeHiPSProjectionCenterAndType, changeHiPSProjectionCenter } from '../WebPlot.js'; import {PlotAttribute} from '../PlotAttribute.js'; import {replaceHiPSProjection} from '../HiPSUtil.js'; @@ -33,7 +36,6 @@ import { convertImageIdxToHDU, hasLocalStretchByteData } from '../PlotViewUtil.js'; import Point, {parseAnyPt, makeImagePt, makeWorldPt, makeDevicePt} from '../Point.js'; -import {UserZoomTypes} from '../ZoomUtil.js'; import {updateTransform} from '../PlotTransformUtils.js'; import {WebPlotRequest, WPConst} from '../WebPlotRequest.js'; @@ -76,33 +78,32 @@ function replaceAtt(pv,att, toAll) { export function reducer(state, action) { - const retState= state; switch (action.type) { - case Cntlr.ZOOM_HIPS : return zoomSetup(state, action); - case Cntlr.ZOOM_IMAGE : return updateDisplayData(zoomSetup(state, action),action); - case Cntlr.COLOR_CHANGE : - case Cntlr.STRETCH_CHANGE : return updateDisplayData(state,action); - case Cntlr.UPDATE_VIEW_SIZE : return updateViewSize(state,action); - case Cntlr.PROCESS_SCROLL : return processScroll(state,action); - case Cntlr.CHANGE_CENTER_OF_PROJECTION: return processProjectionChange(state,action); - case Cntlr.CHANGE_HIPS : return changeHiPS(state,action); - case Cntlr.RECENTER: return recenter(state,action); - case Cntlr.ROTATE: return updateClientRotation(state,action); - case Cntlr.FLIP: return updateClientFlip(state,action); - case Cntlr.CHANGE_PLOT_ATTRIBUTE : return changePlotAttribute(state,action); - case Cntlr.ZOOM_LOCKING: return changeLocking(state,action); - case Cntlr.POSITION_LOCKING: return changePositionLocking(state,action); - case Cntlr.OVERLAY_COLOR_LOCKING: return changeOverlayColorLocking(state,action); - case Cntlr.PLOT_PROGRESS_UPDATE : return updatePlotProgress(state,action); - case Cntlr.CHANGE_PRIME_PLOT : return makeNewPrimePlot(state,action); - case Cntlr.OVERLAY_PLOT_CHANGE_ATTRIBUTES : return changeOverlayPlotAttributes(state,action); - case Cntlr.CHANGE_HIPS_IMAGE_CONVERSION : return changeHipsImageConversionSettings(state,action); - case Cntlr.BYTE_DATA_REFRESH: return markByteDataRefresh(state,action); - case Cntlr.CHANGE_IMAGE_VISIBILITY: return changeVisibility(state,action); - case Cntlr.REQUEST_LOCAL_DATA: return requestLocalData(state,action); - case Cntlr.CHANGE_SUBHIGHLIGHT_PLOT_VIEW: return changeSubHighPlotView(state,action); - case Cntlr.MARK_OUT_OF_MEMORY: return doMarkOutOfMemory(state,action); + case ZOOM_HIPS : return zoomSetup(state, action); + case ZOOM_IMAGE : return updateDisplayData(zoomSetup(state, action),action); + case COLOR_CHANGE : + case STRETCH_CHANGE : return updateDisplayData(state,action); + case UPDATE_VIEW_SIZE : return updateViewSize(state,action); + case PROCESS_SCROLL : return processScroll(state,action); + case CHANGE_CENTER_OF_PROJECTION: return processProjectionChange(state,action); + case CHANGE_HIPS : return changeHiPS(state,action); + case RECENTER: return recenter(state,action); + case ROTATE: return updateClientRotation(state,action); + case FLIP: return updateClientFlip(state,action); + case CHANGE_PLOT_ATTRIBUTE : return changePlotAttribute(state,action); + case ZOOM_LOCKING: return changeLocking(state,action); + case POSITION_LOCKING: return changePositionLocking(state,action); + case OVERLAY_COLOR_LOCKING: return changeOverlayColorLocking(state,action); + case PLOT_PROGRESS_UPDATE : return updatePlotProgress(state,action); + case CHANGE_PRIME_PLOT : return makeNewPrimePlot(state,action); + case OVERLAY_PLOT_CHANGE_ATTRIBUTES : return changeOverlayPlotAttributes(state,action); + case CHANGE_HIPS_IMAGE_CONVERSION : return changeHipsImageConversionSettings(state,action); + case BYTE_DATA_REFRESH: return markByteDataRefresh(state,action); + case CHANGE_IMAGE_VISIBILITY: return changeVisibility(state,action); + case REQUEST_LOCAL_DATA: return requestLocalData(state,action); + case CHANGE_SUBHIGHLIGHT_PLOT_VIEW: return changeSubHighPlotView(state,action); + case MARK_OUT_OF_MEMORY: return doMarkOutOfMemory(state,action); } return retState; } @@ -224,10 +225,10 @@ function updateImageDisplayData(state,action) { const inPlot= primePlot(inPv); let pv= {...inPv, serverCall:'success'}; - const zoomFactor= (action.type===Cntlr.ZOOM_IMAGE) ? newZoomFactor : inPlot.zoomFactor; + const zoomFactor= (action.type===ZOOM_IMAGE) ? newZoomFactor : inPlot.zoomFactor; pv= replacePrimaryPlot(pv, WebPlot.replacePlotValues(inPlot,primaryStateJson,zoomFactor, rawData,colorTableId, bias,contrast,nanPixelColor,useRed,useGreen,useBlue)); - if (action.type===Cntlr.COLOR_CHANGE && !isThreeColor(pv)) { + if (action.type===COLOR_CHANGE && !isThreeColor(pv)) { const cId= primePlot(pv).colorTableId; pv.plots= pv.plots.map( (p) => { const newP={...p,colorTableId:cId}; @@ -263,7 +264,7 @@ function updateImageDisplayData(state,action) { const plot= primePlot(pv); // get the updated on let newPlotGroupAry= plotGroupAry; - if (action.type===Cntlr.STRETCH_CHANGE) { + if (action.type===STRETCH_CHANGE) { pv= updateForStretch(pv,plot); const rv= plot.plotState.getRangeValues(); newPlotGroupAry= plotGroupAry.map( (g) => g.plotGroupId===pv.plotGroupId ? {...g,defaultRangeValues:rv} : g); @@ -464,7 +465,6 @@ function rotatePvToMatch(pv, masterPv, rotateNorthLock) { } - /** * @param {VisRoot} state * @param {Action} action @@ -828,9 +828,6 @@ function requestLocalData(state, action) { const plots= pv.plots.map( (p) => p.plotImageId===plotImageId ? {...p,dataRequested}: p); updatedPv= {...pv,plots}; } - - - const plotViewAry= replacePlotView(state.plotViewAry,updatedPv); return {...state, plotViewAry}; } @@ -841,8 +838,6 @@ function updatePlotProgress(state,action) { const plot= primePlot(plotView); // validate the update - - if (!plotView) return state; if (requestKey!==plotView.request.getRequestKey()) return state; if (plotView.plottingStatusMsg===plottingStatusMsg) return state; diff --git a/src/firefly/js/visualize/reducer/HandlePlotCreation.js b/src/firefly/js/visualize/reducer/HandlePlotCreation.js index 80657849b3..fe89405f7f 100644 --- a/src/firefly/js/visualize/reducer/HandlePlotCreation.js +++ b/src/firefly/js/visualize/reducer/HandlePlotCreation.js @@ -3,7 +3,10 @@ */ import {uniqBy, differenceBy, isEmpty, isNumber, isString, uniq} from 'lodash'; -import Cntlr, {WcsMatchType} from '../ImagePlotCntlr.js'; +import { + CROP, CROP_FAIL, CROP_START, DELETE_OVERLAY_PLOT, PLOT_HIPS, PLOT_HIPS_FAIL, PLOT_IMAGE, PLOT_IMAGE_FAIL, + PLOT_IMAGE_START, PLOT_MASK, PLOT_MASK_FAIL, PLOT_MASK_START, PLOT_PROXY, REMOVE_PROXY, WcsMatchType +} from '../VisConst'; import {getRotationAngle} from '../WebPlotAnalysis'; import { replacePlots, makePlotView, updatePlotViewScrollXY, @@ -12,7 +15,9 @@ import { import {makeOverlayPlotView, initOverlayPlots} from './OverlayPlotView.js'; import { primePlot, getPlotViewById, clonePvAry, getOverlayById, getPlotViewIdListByPositionLock, - getCubePlaneCnt, getHDU, getImageCubeIdx, } from '../PlotViewUtil.js'; import {getPlotGroupById, makePlotGroup} from '../PlotGroup.js'; + getCubePlaneCnt, getHDU, getImageCubeIdx +} from '../PlotViewUtil.js'; +import {getPlotGroupById, makePlotGroup} from '../PlotGroup.js'; import {PlotAttribute} from '../PlotAttribute.js'; import {CCUtil} from '../CsysConverter.js'; import {updateTransform} from '../PlotTransformUtils.js'; @@ -22,66 +27,39 @@ import {getNumberHeader, HdrConst} from 'firefly/visualize/FitsHeaderUtil.js'; export function reducer(state, action) { - - let retState= state; switch (action.type) { - case Cntlr.PLOT_IMAGE_START : - retState= startPlot(state,action); - break; - case Cntlr.PLOT_IMAGE_FAIL : - retState= plotFail(state,action); - break; - case Cntlr.PLOT_IMAGE : + case PLOT_IMAGE_START : + return startPlot(state,action); + case PLOT_IMAGE_FAIL : + return plotFail(state,action); + case PLOT_IMAGE : const {setNewPlotAsActive=true}= action.payload; - retState= addPlot(state,action, action.payload.setNewPlotAsActive, setNewPlotAsActive); - break; - case Cntlr.PLOT_PROXY: - retState= addProxy(state,action); - break; - case Cntlr.REMOVE_PROXY: - retState= removeProxy(state,action); - break; - - case Cntlr.PLOT_HIPS : - retState= addHiPS(state,action); - break; - - case Cntlr.PLOT_HIPS_FAIL : - retState= hipsFail(state,action); - break; - - case Cntlr.PLOT_MASK_START: - retState= newOverlayPrep(state,action); - break; - - case Cntlr.PLOT_MASK: - retState= addOverlay(state,action); - break; - - case Cntlr.DELETE_OVERLAY_PLOT: - retState= removeOverlay(state,action); - break; - - - case Cntlr.PLOT_MASK_FAIL: - retState= plotOverlayFail(state,action); - break; - - case Cntlr.CROP_START: - retState= workingServerCall(state,action); - break; - - case Cntlr.CROP_FAIL: - retState= endServerCallFail(state,action); - break; - - case Cntlr.CROP: - retState= addPlot(state,action, false, false); - break; + return addPlot(state,action, action.payload.setNewPlotAsActive, setNewPlotAsActive); + case PLOT_PROXY: + return addProxy(state,action); + case REMOVE_PROXY: + return removeProxy(state,action); + case PLOT_HIPS : + return addHiPS(state,action); + case PLOT_HIPS_FAIL : + return hipsFail(state,action); + case PLOT_MASK_START: + return newOverlayPrep(state,action); + case PLOT_MASK: + return addOverlay(state,action); + case DELETE_OVERLAY_PLOT: + return removeOverlay(state,action); + case PLOT_MASK_FAIL: + return plotOverlayFail(state,action); + case CROP_START: + return workingServerCall(state,action); + case CROP_FAIL: + return endServerCallFail(state,action); + case CROP: + return addPlot(state,action, false, false); default: - break; + return state; } - return retState; } diff --git a/src/firefly/js/visualize/reducer/PlotView.js b/src/firefly/js/visualize/reducer/PlotView.js index 4ded8e08c7..affd7078c5 100644 --- a/src/firefly/js/visualize/reducer/PlotView.js +++ b/src/firefly/js/visualize/reducer/PlotView.js @@ -12,13 +12,11 @@ import {makeScreenPt, makeDevicePt, makeImagePt, makeWorldPt} from '../Point'; import {getActiveTarget} from '../../core/AppDataCntlr.js'; import {getLatDist, getLonDist} from '../VisUtil.js'; import {findCurrentCenterPoint, getPlotViewById, hasWCSProjection, matchPlotViewByPositionGroup, primePlot} from '../PlotViewUtil.js'; -import {UserZoomTypes} from '../ZoomUtil.js'; -import {ZoomType} from '../ZoomType.js'; import {PlotPref} from '../PlotPref.js'; import {DEFAULT_THUMBNAIL_SIZE} from '../WebPlotRequest.js'; import {CCUtil, CysConverter} from '../CsysConverter.js'; import {getDefMenuItemKeys} from '../MenuItemKeys.js'; -import {ExpandType, WcsMatchType} from '../ImagePlotCntlr.js'; +import {ExpandType, UserZoomTypes, WcsMatchType, ZoomType} from '../VisConst'; import {updateTransform, makeTransform} from '../PlotTransformUtils.js'; // export const ServerCallStatus= new Enum(['success', 'working', 'fail'], { ignoreCase: true }); diff --git a/src/firefly/js/visualize/region/RegionArea.js b/src/firefly/js/visualize/region/RegionArea.js index a061f5511f..2389b13a9f 100644 --- a/src/firefly/js/visualize/region/RegionArea.js +++ b/src/firefly/js/visualize/region/RegionArea.js @@ -6,22 +6,15 @@ * This Object contains the specifications of the DS9 region */ -import {visRoot} from '../ImagePlotCntlr.js'; -import {primePlot} from '../PlotViewUtil.js'; +import {currentP} from '../PlotViewUtil.js'; import {makeScreenPt} from '../Point.js'; import {CysConverter} from '../CsysConverter.js'; import {RegionType} from './Region.js'; -import {get} from 'lodash'; export function getRegionArea(region, cc) { - var rCover = null; - if (!cc) { - var plotId = get(visRoot(), 'activePlotId'); - var plot = primePlot(visRoot(), plotId); - cc = CysConverter.make(plot); - } - + let rCover; + if (!cc) cc = CysConverter.make(currentP().plot); if (region.type === RegionType.polygon) { rCover = getRegionLinesArea(region.wpAry, cc); } diff --git a/src/firefly/js/visualize/region/RegionDescription.js b/src/firefly/js/visualize/region/RegionDescription.js index 09e62ec5d7..3b5331a61a 100644 --- a/src/firefly/js/visualize/region/RegionDescription.js +++ b/src/firefly/js/visualize/region/RegionDescription.js @@ -2,16 +2,14 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import {visRoot} from '../ImagePlotCntlr.js'; -import {getAllDrawLayersForPlot} from '../PlotViewUtil.js'; -import {getDlAry} from '../DrawLayerCntlr.js'; +import {currentP, getAllDrawLayersForPlot} from '../PlotViewUtil.js'; import {DataTypes} from '../draw/DrawLayer.js'; import DrawOp from '../draw/DrawOp.js'; import Point from '../Point.js'; +import {getDlAry} from '../VisStoreRoots'; import {RegionType, regionPropsList, getRegionDefault, RegionValue, RegionValueUnit} from './Region.js'; import {get, has, isNil, isEmpty} from 'lodash'; import {MARKER_DATA_OBJ, markerToRegion} from '../draw/MarkerFootprintObj.js'; -import CysConverter from '../CsysConverter.js'; const RegionPropertyName = { @@ -59,10 +57,10 @@ var fontObjToStr = (v) => (`"${v.name} ${v.point} ${v.weight} ${v.slant}"` ); */ export function makeRegionsFromPlot(plot, bSeperateText = false) { - var plotId = plot? plot.plotId : get(visRoot(), 'avtivePlotId'); - var dlAry = getAllDrawLayersForPlot(getDlAry(), plotId, true ); + const plotId = plot? plot.plotId : currentP().plotId; + const dlAry = getAllDrawLayersForPlot(getDlAry(), plotId, true ); var oneRegionDes; - var rgDesAry = []; + const rgDesAry = []; /* const DS9Ver = '# Region file format: DS9 version 4.1'; var DS9Global = 'global'; diff --git a/src/firefly/js/visualize/region/RegionFileUploadView.jsx b/src/firefly/js/visualize/region/RegionFileUploadView.jsx index 33cab3a18f..3793e1db3d 100644 --- a/src/firefly/js/visualize/region/RegionFileUploadView.jsx +++ b/src/firefly/js/visualize/region/RegionFileUploadView.jsx @@ -10,7 +10,6 @@ import React, {useState} from 'react'; import DialogRootContainer from '../../ui/DialogRootContainer.jsx'; import {dispatchShowDialog} from '../../core/ComponentCntlr.js'; import HelpIcon from '../../ui/HelpIcon.jsx'; -import {dispatchCreateRegionLayer, dispatchCreateFootprintLayer} from '../DrawLayerCntlr.js'; import {PopupPanel} from '../../ui/PopupPanel.jsx'; import {FieldGroup} from '../../ui/FieldGroup.jsx'; import {FileUpload} from '../../ui/FileUpload.jsx'; @@ -21,6 +20,7 @@ import {createNewRegionLayerId, getRegionLayerTitle} from '../../drawingLayers/R import {relocatable} from '../../drawingLayers/FootprintLocatable.js'; import {createNewFootprintLayerId, getFootprintLayerTitle} from '../../drawingLayers/FootprintTool.js'; import {CheckboxGroupInputField} from '../../ui/CheckboxGroupInputField.jsx'; +import {dispatchCreateFootprintLayer, dispatchCreateRegionLayer} from '../DrawLayerDispatch'; const popupId = 'RegionFilePopup'; const rgUploadGroupKey = 'RegionUploadGroup'; diff --git a/src/firefly/js/visualize/region/RegionTask.js b/src/firefly/js/visualize/region/RegionTask.js index 9aaf533a54..6525c1bb56 100644 --- a/src/firefly/js/visualize/region/RegionTask.js +++ b/src/firefly/js/visualize/region/RegionTask.js @@ -3,14 +3,13 @@ */ import {getDS9Region} from '../../rpc/PlotServicesJson.js'; -import {getDlAry} from '../DrawLayerCntlr.js'; -import DrawLayerCntrl, {dispatchCreateDrawLayer, dispatchDetachLayerFromPlot, - dispatchAttachLayerToPlot} from '../DrawLayerCntlr.js'; -import {getDrawLayerById, getPlotViewIdListInOverlayGroup} from '../PlotViewUtil.js'; +import {dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDetachLayerFromPlot} from '../DrawLayerDispatch'; +import {currentP, getDrawLayerById, getPlotViewIdListInOverlayGroup} from '../PlotViewUtil.js'; import RegionPlot, {createNewRegionLayerId, getRegionLayerTitle} from '../../drawingLayers/RegionPlot.js'; -import {visRoot} from '../ImagePlotCntlr.js'; +import {REGION_ADD_ENTRY} from '../VisConst'; +import {getDlAry, visRoot} from '../VisStoreRoots'; import {logger} from '../../util/Logger.js'; -import {has, isArray, isEmpty, get, isNil} from 'lodash'; +import {has, isArray, isEmpty, isNil} from 'lodash'; const regionDrawLayerId = RegionPlot.TYPE_ID; @@ -23,7 +22,7 @@ var [RegionIdErr, RegionErr, NoRegionErr, JSONErr] = [ export const getPlotId = (plotId) => { //return (!plotId || (isArray(plotId)&&plotId.length === 0)) ? get(visRoot(), 'activePlotId') : plotId; if (!plotId || (isArray(plotId)&&plotId.length === 0)) { - const pid = get(visRoot(), 'activePlotId'); + const pid = currentP().plotId; return getPlotViewIdListInOverlayGroup(visRoot(), pid); } else { return plotId; @@ -142,7 +141,7 @@ export function regionUpdateEntryActionCreator(rawAction) { const dl = drawLayerId ? getDrawLayerById(getDlAry(), drawLayerId) : null; // if drawlayer doesn't exist, create a new one - if (!dl && rawAction.type === DrawLayerCntrl.REGION_ADD_ENTRY) { + if (!dl && rawAction.type === REGION_ADD_ENTRY) { const title = getRegionLayerTitle(layerTitle); createRegionLayer(changes, title, drawLayerId, plotId, selectMode); diff --git a/src/firefly/js/visualize/saga/ActiveRowToImageWatcher.js b/src/firefly/js/visualize/saga/ActiveRowToImageWatcher.js index 15a506c696..54338014cf 100644 --- a/src/firefly/js/visualize/saga/ActiveRowToImageWatcher.js +++ b/src/firefly/js/visualize/saga/ActiveRowToImageWatcher.js @@ -6,19 +6,19 @@ import {isString, isObject, once} from 'lodash'; import {TABLE_LOADED, TABLE_SELECT,TABLE_HIGHLIGHT,TABLE_REMOVE,TABLE_UPDATE,TBL_RESULTS_ACTIVE} from '../../tables/TablesCntlr.js'; import {isDefined} from '../../util/WebUtil'; import {findTableCenterColumns} from '../../voAnalyzer/TableAnalysis.js'; -import {visRoot, dispatchRecenter, dispatchChangeSubHighPlotView} from '../ImagePlotCntlr.js'; +import {visRoot} from '../VisStoreRoots'; +import { + dispatchChangeSubHighPlotView, dispatchPlotImage, dispatchRecenter, dispatchUseTableAutoScroll +} from '../ImagePlotDispatch'; import { getTblById, getCellValue, hasSubHighlightRows, isSubHighlightRow, getActiveTableId } from '../../tables/TableUtil.js'; import {getMultiViewRoot, getViewer} from '../MultiViewCntlr'; import {computeBoundingBoxInDeviceCoordsForPlot, isFullyOnScreen} from '../WebPlotAnalysis'; import {makeAnyPt} from '../Point.js'; -import { - DEFAULT_COVERAGE_PLOT_ID, DEFAULT_COVERAGE_VIEWER_ID, getActivePlotView, getPlotViewById, hasWCSProjection, - primePlot, -} from '../PlotViewUtil'; +import {currentP, hasWCSProjection, primePlot} from '../PlotViewUtil'; import {CysConverter} from '../CsysConverter'; -import ImagePlotCntlr, {dispatchPlotImage, dispatchUseTableAutoScroll} from '../ImagePlotCntlr'; +import {ANY_REPLOT, CHANGE_ACTIVE_PLOT_VIEW, DEFAULT_COVERAGE_PLOT_ID, DEFAULT_COVERAGE_VIEWER_ID} from '../VisConst'; import {isTableUsingRadians} from '../../tables/TableUtil'; import {PlotAttribute} from '../PlotAttribute'; import {isImage} from '../WebPlot'; @@ -34,7 +34,7 @@ function willFitOnScreenAtCurrentZoom(pv) { } const getTableActions= () => [TABLE_LOADED, TABLE_SELECT, TABLE_HIGHLIGHT, TABLE_UPDATE, TBL_RESULTS_ACTIVE, TABLE_REMOVE]; -const getImageActions= () => [ImagePlotCntlr.CHANGE_ACTIVE_PLOT_VIEW, ImagePlotCntlr.ANY_REPLOT]; +const getImageActions= () => [CHANGE_ACTIVE_PLOT_VIEW, ANY_REPLOT]; /** @@ -109,12 +109,12 @@ function shouldCenterOnTableRow(pv, wp, force) { } function recenterImageActiveRow(tbl_id, force=false) { - const pv = getActivePlotView(visRoot()); + const {pv} = currentP(); if (!pv) return; recenterPlotViewActiveRow(pv, tbl_id, force); if (pv.plotId!==DEFAULT_COVERAGE_PLOT_ID) { const covView=getViewer(getMultiViewRoot(),DEFAULT_COVERAGE_VIEWER_ID); - const covPv = getPlotViewById(visRoot(),DEFAULT_COVERAGE_PLOT_ID); + const {pv:covPv}= currentP(DEFAULT_COVERAGE_PLOT_ID); if (!covPv || !covView.mounted) return; recenterPlotViewActiveRow(covPv, tbl_id, force); diff --git a/src/firefly/js/visualize/saga/CatalogWatcher.js b/src/firefly/js/visualize/saga/CatalogWatcher.js index d1a067eb84..b6b5f1339b 100644 --- a/src/firefly/js/visualize/saga/CatalogWatcher.js +++ b/src/firefly/js/visualize/saga/CatalogWatcher.js @@ -21,9 +21,10 @@ import {logger} from '../../util/Logger'; import { findImageCenterColumns, getSearchTarget, isCatalog } from '../../voAnalyzer/TableAnalysis.js'; import { dispatchAttachLayerToPlot, dispatchChangeVisibility, dispatchCreateDrawLayer, dispatchDestroyDrawLayer, - dispatchModifyCustomField, dlRoot, SUBGROUP, -} from '../DrawLayerCntlr.js'; -import ImagePlotCntlr, {visRoot} from '../ImagePlotCntlr.js'; + dispatchModifyCustomField +} from '../DrawLayerDispatch'; +import {PLOT_HIPS, PLOT_IMAGE, SUBGROUP} from '../VisConst'; +import {dlRoot, visRoot} from '../VisStoreRoots'; import {PlotAttribute} from '../PlotAttribute.js'; import { getDrawLayerById, getPlotViewAry, getPlotViewById, isDrawLayerAttached, isDrawLayerVisible, @@ -41,8 +42,7 @@ export const getCatalogWatcherDef= once(() => ( watcher : watchCatalogs, testTable : (table) => !isLsstFootprintTable(table) && isCatalog(table), allowMultiples: false, - actions: [TABLE_LOADED, TABLE_SELECT, TABLE_HIGHLIGHT, TBL_RESULTS_ACTIVE, - TABLE_REMOVE, ImagePlotCntlr.PLOT_IMAGE, ImagePlotCntlr.PLOT_HIPS] + actions: [TABLE_LOADED, TABLE_SELECT, TABLE_HIGHLIGHT, TBL_RESULTS_ACTIVE, TABLE_REMOVE, PLOT_IMAGE, PLOT_HIPS] } )); @@ -114,8 +114,8 @@ export function watchCatalogs(tbl_id, action, cancelSelf, params) { cancelSelf(); break; - case ImagePlotCntlr.PLOT_HIPS: - case ImagePlotCntlr.PLOT_IMAGE: + case PLOT_HIPS: + case PLOT_IMAGE: attachToCatalog(tbl_id, payload); break; } diff --git a/src/firefly/js/visualize/saga/CoverageUtil.jsx b/src/firefly/js/visualize/saga/CoverageUtil.jsx index a27cd07ff0..5f981825fd 100644 --- a/src/firefly/js/visualize/saga/CoverageUtil.jsx +++ b/src/firefly/js/visualize/saga/CoverageUtil.jsx @@ -8,9 +8,10 @@ import {getTblById} from '../../tables/TableUtil'; import {parseObsCoreRegion} from '../../util/ObsCoreSRegionParser'; import {memorizeLastCall} from '../../util/WebUtil'; import {findTableRegionColumn, isOrbitalPathTable, isTableWithRegion} from '../../voAnalyzer/TableAnalysis'; -import {dispatchAttributeChange, visRoot} from '../ImagePlotCntlr'; +import {dispatchAttributeChange} from '../ImagePlotDispatch'; import {PlotAttribute} from '../PlotAttribute'; -import {DEFAULT_COVERAGE_PLOT_ID, primePlot} from '../PlotViewUtil'; +import {currentP} from '../PlotViewUtil'; +import {DEFAULT_COVERAGE_PLOT_ID} from '../VisConst'; import {DrawLayersButton} from '../ui/Buttons'; import {showDrawingLayerPopup} from '../ui/DrawLayerPanel'; @@ -35,7 +36,7 @@ export function updateWarnings(preparedTables, options) { }) .filter(Boolean); - const plot = primePlot(visRoot(), DEFAULT_COVERAGE_PLOT_ID); + const {plot} = currentP(DEFAULT_COVERAGE_PLOT_ID); if (!plot) return; const warnings = {}; diff --git a/src/firefly/js/visualize/saga/CoverageWatcher.js b/src/firefly/js/visualize/saga/CoverageWatcher.js index 0501702650..801e525260 100644 --- a/src/firefly/js/visualize/saga/CoverageWatcher.js +++ b/src/firefly/js/visualize/saga/CoverageWatcher.js @@ -5,8 +5,8 @@ import Enum from 'enum'; import {flattenDeep, isEmpty, isObject, isString, isUndefined, pick, values} from 'lodash'; import {getAppOptions} from '../../core/AppDataCntlr'; -import {REINIT_APP} from '../../core/AppDataCntlr.js'; import {dispatchComponentStateChange, getComponentState} from '../../core/ComponentCntlr.js'; +import {REINIT_APP} from '../../core/CoreConst'; import {dispatchAddTableTypeWatcherDef} from '../../core/MasterSaga'; import {MetaConst} from '../../data/MetaConst.js'; import Catalog from '../../drawingLayers/Catalog.js'; @@ -33,19 +33,19 @@ import CoordSys from '../CoordSys'; import {getNextColor} from '../draw/DrawingDef.js'; import {DrawSymbol} from '../draw/DrawSymbol.js'; import { - dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDestroyDrawLayer, dispatchModifyCustomField, dlRoot, - getDlAry -} from '../DrawLayerCntlr.js'; + dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDestroyDrawLayer, dispatchModifyCustomField +} from '../DrawLayerDispatch'; import {getCornersForCell} from '../HiPSUtil'; -import ImagePlotCntlr, { - dispatchDeletePlotView, dispatchPlotHiPS, dispatchPlotImageOrHiPS, visRoot -} from '../ImagePlotCntlr.js'; -import MultiViewCntlr, {getMultiViewRoot, getViewer} from '../MultiViewCntlr.js'; +import {dispatchDeletePlotView, dispatchPlotHiPS, dispatchPlotImageOrHiPS} from '../ImagePlotDispatch'; +import { + ADD_VIEWER, DEFAULT_COVERAGE_PLOT_ID, PLOT_HIPS, PLOT_IMAGE, VIEWER_MOUNTED, VIEWER_UNMOUNTED +} from '../VisConst'; +import {getMultiViewRoot, getViewer } from '../MultiViewCntlr.js'; import {PlotAttribute} from '../PlotAttribute.js'; import {onPlotComplete} from '../PlotCompleteMonitor'; -import {DEFAULT_COVERAGE_PLOT_ID, getDrawLayersByType, isDrawLayerAttached, isDrawLayerVisible} from '../PlotViewUtil'; -import {getDrawLayerById, primePlot} from '../PlotViewUtil.js'; +import {getDrawLayerById, getDrawLayersByType, isDrawLayerAttached, isDrawLayerVisible, currentP} from '../PlotViewUtil'; import {makeWorldPt, pointEquals} from '../Point.js'; +import {dlRoot, getDlAry} from '../VisStoreRoots'; import {computeCentralPtRadiusAverage} from '../VisUtil.js'; import {BLANK_HIPS_URL, isBlankHiPSURL, isHiPS} from '../WebPlot'; import {WebPlotRequest} from '../WebPlotRequest.js'; @@ -157,8 +157,7 @@ export const getCoverageWatcherDef = () => ({ watcher : watchCoverage, allowMultiples: false, actions: [TABLE_LOADED, TABLE_SELECT,TABLE_HIGHLIGHT, TABLE_REMOVE, - ImagePlotCntlr.PLOT_IMAGE, ImagePlotCntlr.PLOT_HIPS, - MultiViewCntlr.ADD_VIEWER, MultiViewCntlr.VIEWER_MOUNTED, MultiViewCntlr.VIEWER_UNMOUNTED] + PLOT_IMAGE, PLOT_HIPS, ADD_VIEWER, VIEWER_MOUNTED, VIEWER_UNMOUNTED] }); const getOptions= (inputOptions) => ({...defOptions, ...cleanUpOptions(inputOptions)}); @@ -225,7 +224,7 @@ function watchCoverage(tbl_id, action, cancelSelf, params) { return; } - if (action.type===MultiViewCntlr.VIEWER_MOUNTED || action.type===MultiViewCntlr.ADD_VIEWER) { + if (action.type===VIEWER_MOUNTED || action.type===ADD_VIEWER) { setPreferredHipsOnSharedData(); updateCoverage(tbl_id, viewerId, preparedTables, options, tblCatIdMap, sharedData.preferredHipsSourceURL, sharedData.preferredHipsSource360URL); return {paused:false}; @@ -257,12 +256,12 @@ function watchCoverage(tbl_id, action, cancelSelf, params) { handleSelectOrHighlight(action,tblCatIdMap,tbl_id); break; - case MultiViewCntlr.VIEWER_UNMOUNTED: + case VIEWER_UNMOUNTED: paused = true; break; - case ImagePlotCntlr.PLOT_IMAGE: - case ImagePlotCntlr.PLOT_HIPS: + case PLOT_IMAGE: + case PLOT_HIPS: if (action.payload.plotId===DEFAULT_COVERAGE_PLOT_ID) { setTimeout( () => overlayCoverageDrawing(preparedTables,options, tblCatIdMap, undefined), 5); } @@ -436,7 +435,7 @@ function updateCoverageWithData(viewerId, table, options, tbl_id, preparedTable, } const tblIdAry= Object.keys(preparedTables).filter( (v) => !isString(preparedTables[v])); - const plot= primePlot(visRoot(), DEFAULT_COVERAGE_PLOT_ID); + const {plot}= currentP(DEFAULT_COVERAGE_PLOT_ID); const oldAtt= plot?.attributes ?? {}; const pickList= (isHiPS(plot)) ? [...baseAttributePickList, ...selAttributePickList] : [...baseAttributePickList]; @@ -582,7 +581,7 @@ function makeOverlayCoverageDrawing() { * @param {String} affectedTblId - the table id that is affected */ return (preparedTables, options, tblCatIdMap, affectedTblId) => { - const plot= primePlot(visRoot(),DEFAULT_COVERAGE_PLOT_ID); + const {plot}= currentP(DEFAULT_COVERAGE_PLOT_ID); if (!plot && !affectedTblId) return; const tblIdAry= plot ? plot.attributes[PlotAttribute.VISUALIZED_TABLE_IDS] : [affectedTblId]; if (isEmpty(tblIdAry)) return; @@ -887,7 +886,7 @@ function findPreferredHiPS(tbl_id,prevPreferredHipsSourceURL, optionHipsSourceUR if (covHips) return makeRet(covHips,covHips); if (sim) return makeRet(BLANK_HIPS_URL, BLANK_HIPS_URL); } - const plot= primePlot(visRoot(), DEFAULT_COVERAGE_PLOT_ID); + const {plot}= currentP(DEFAULT_COVERAGE_PLOT_ID); if (isHiPS(plot)) { return makeRet(plot.hipsUrlRoot, plot.hipsUrlRoot); } diff --git a/src/firefly/js/visualize/saga/MOCWatcher.js b/src/firefly/js/visualize/saga/MOCWatcher.js index d40a93c19c..4a14b10b26 100644 --- a/src/firefly/js/visualize/saga/MOCWatcher.js +++ b/src/firefly/js/visualize/saga/MOCWatcher.js @@ -3,14 +3,15 @@ */ import {once} from 'lodash'; -import {dispatchAttachLayerToPlot} from '../DrawLayerCntlr.js'; -import {visRoot} from '../ImagePlotCntlr.js'; +import {dispatchAttachLayerToPlot} from '../DrawLayerDispatch'; +import {visRoot} from '../VisStoreRoots'; import {getTblById} from '../../tables/TableUtil.js'; import {addNewMocLayer, getAppHiPSForMoc, isTableMOC} from '../HiPSMocUtil.js'; -import {getActivePlotView, getNextHiPSPlotId, getPlotViewAry, primePlot} from '../PlotViewUtil.js'; +import {currentP, getNextHiPSPlotId, getPlotViewAry, primePlot} from '../PlotViewUtil.js'; import WebPlotRequest from '../WebPlotRequest.js'; -import {getAViewFromMultiView, getMultiViewRoot, IMAGE} from '../MultiViewCntlr.js'; -import {dispatchPlotHiPS} from '../ImagePlotCntlr'; +import {IMAGE} from '../VisConst'; +import {getAViewFromMultiView, getMultiViewRoot} from '../MultiViewCntlr.js'; +import {dispatchPlotHiPS} from '../ImagePlotDispatch'; import {MetaConst} from '../../data/MetaConst.js'; import {isHiPS} from '../WebPlot.js'; import {RequestType} from '../RequestType'; @@ -101,7 +102,7 @@ function findHiPSWithSource(url) { * @return {String} plotId */ function findAnyHiPS() { - const activePV= getActivePlotView(visRoot()); + const {pv:activePV}= currentP(); if (isHiPSDeferred(activePV)) return activePV.plotId; const foundPv= getPlotViewAry(visRoot()).find( (pv) => isHiPSDeferred(pv)); return foundPv && foundPv.plotId; diff --git a/src/firefly/js/visualize/saga/MouseReadoutWatch.js b/src/firefly/js/visualize/saga/MouseReadoutWatch.js index d55f131496..cc389f79a0 100644 --- a/src/firefly/js/visualize/saga/MouseReadoutWatch.js +++ b/src/firefly/js/visualize/saga/MouseReadoutWatch.js @@ -3,7 +3,6 @@ */ import {race,call} from 'redux-saga/effects'; -import {visRoot} from '../ImagePlotCntlr.js'; import {clone} from '../../util/WebUtil.js'; import { readoutRoot, makeValueReadoutItem, makePointReadoutItem, @@ -18,9 +17,9 @@ import {getPixScale, getScreenPixScale, getScreenPixScaleArcSec, isImage, isHiPS import {getPlotTilePixelAngSize} from '../HiPSUtil.js'; import {mouseUpdatePromise, fireMouseReadoutChange} from '../VisMouseSync'; import { - primePlot, getPlotStateAry, getPlotViewById, getImageCubeIdx, + primePlot, getPlotStateAry, getImageCubeIdx, getWavelengthParseFailReason, getWaveLengthUnits, hasPixelLevelWLInfo, hasPlaneOnlyWLInfo, - isImageCube, wavelengthInfoParsedSuccessfully, getPtSpectralCoords, getBandWidthUnits, isThreeColor, + isImageCube, wavelengthInfoParsedSuccessfully, getPtSpectralCoords, getBandWidthUnits, isThreeColor, currentP, } from '../PlotViewUtil'; import {getFluxRadix} from 'firefly/visualize/ui/MouseReadoutUIUtil'; @@ -66,8 +65,7 @@ export function* watchReadout() { if (lockByClick && worldPt && !shiftDown && mouseState===MouseState.CLICK) savedWP= worldPt; } - const plotView= getPlotViewById(visRoot(), plotId); - const plot= primePlot(plotView); + const {plot,pv:plotView}= currentP(plotId); const threeColor= plot?.plotState?.threeColor; if (useEv) { diff --git a/src/firefly/js/visualize/task/CreateTaskUtil.js b/src/firefly/js/visualize/task/CreateTaskUtil.js index 94f4abe80a..2c151756da 100644 --- a/src/firefly/js/visualize/task/CreateTaskUtil.js +++ b/src/firefly/js/visualize/task/CreateTaskUtil.js @@ -1,4 +1,7 @@ import {isArray, uniqueId} from 'lodash'; +import { + dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDestroyDrawLayer, dispatchDetachLayerFromPlot +} from '../DrawLayerDispatch'; import {getRotationAngle, isPlotRotatedNorth} from '../WebPlotAnalysis'; import {setActiveRequestKey} from './ActivePlottingTask.js'; import { @@ -9,18 +12,14 @@ import {PlotAttribute} from '../PlotAttribute.js'; import {GridOnStatus, WebPlotRequest} from '../WebPlotRequest.js'; import CsysConverter from '../CsysConverter.js'; import {Band} from '../Band.js'; -import {makeUniqueRequestKey, visRoot} from '../ImagePlotCntlr.js'; -import { DEFAULT_FITS_VIEWER_ID, findViewerWithItemId, getMultiViewRoot, IMAGE } from '../MultiViewCntlr.js'; +import {findViewerWithItemId, getMultiViewRoot} from '../MultiViewCntlr.js'; +import {DEFAULT_FITS_VIEWER_ID, IMAGE, ZoomType} from '../VisConst'; +import {dlRoot, getDlAry, visRoot} from '../VisStoreRoots'; import {isImage, processHeaderData, RDConst} from '../WebPlot.js'; import {enableRelatedDataLayer} from '../RelatedDataUtil.js'; import {getArcSecPerPix} from '../ZoomUtil.js'; -import {ZoomType} from '../ZoomType.js'; import {isDefined} from '../../util/WebUtil.js'; import {HdrConst} from '../FitsHeaderUtil.js'; -import { - dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDestroyDrawLayer, dispatchDetachLayerFromPlot, dlRoot, - getDlAry -} from '../DrawLayerCntlr.js'; import ImageRoot from '../../drawingLayers/ImageRoot.js'; import SearchTarget from '../../drawingLayers/SearchTarget.js'; import HiPSGrid from '../../drawingLayers/HiPSGrid.js'; @@ -141,6 +140,16 @@ export function makeSinglePlotPayload(vr, rawPayload, requestKey) { return payload; } +const KEY_ROOT = 'progress-'; +let keyCnt = 0; + +// todo find the right place for this function when I revamp the plot progress, keep here for now +export function makeUniqueRequestKey(prefix = KEY_ROOT) { + const requestKey = `${prefix}-${keyCnt}-${Date.now()}`; + keyCnt++; + return requestKey; +} + export function makeGroupPayload(vr, rawPayload, requestKey) { const { viewerId = DEFAULT_FITS_VIEWER_ID, attributes, setNewPlotAsActive = true, pvOptions = {}, wpRequestAry, diff --git a/src/firefly/js/visualize/task/ImageOverlayTask.js b/src/firefly/js/visualize/task/ImageOverlayTask.js index 7e81e21716..642e83a365 100644 --- a/src/firefly/js/visualize/task/ImageOverlayTask.js +++ b/src/firefly/js/visualize/task/ImageOverlayTask.js @@ -2,22 +2,21 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ import {logger} from '../../util/Logger.js'; -import ImagePlotCntlr, { - makeUniqueRequestKey, IMAGE_PLOT_KEY, dispatchPlotMaskLazyLoad, visRoot -} from '../ImagePlotCntlr.js'; -import { primePlot, getOverlayByPvAndId, getPlotViewById, - getOverlayById, - convertImageIdxToHDU, +import {dispatchPlotMaskLazyLoad} from '../ImagePlotDispatch'; +import { + primePlot, getOverlayByPvAndId, getPlotViewById, getOverlayById, convertImageIdxToHDU, isPlotIdInPvNewPlotInfoAry, + currentP, } from '../PlotViewUtil.js'; import {PlotState} from '../PlotState.js'; import {RequestType} from '../RequestType.js'; -import {ZoomType} from '../ZoomType.js'; +import { + IMAGE_PLOT_KEY, OVERLAY_PLOT_CHANGE_ATTRIBUTES, PLOT_IMAGE, PLOT_IMAGE_FAIL, PLOT_MASK, PLOT_MASK_FAIL, PLOT_MASK_START, ZoomType +} from '../VisConst'; import {WebPlot} from '../WebPlot.js'; import {callGetWebPlot} from '../../rpc/PlotServicesJson.js'; import {dispatchAddActionWatcher} from '../../core/MasterSaga'; -import {isPlotIdInPvNewPlotInfoAry} from '../PlotViewUtil'; import {changeLocalMaskColorOnOverlayPlotView} from 'firefly/visualize/rawData/RawDataOps.js'; -import {makeCubeCtxAry, populateFromHeader} from 'firefly/visualize/task/CreateTaskUtil.js'; +import {makeCubeCtxAry, makeUniqueRequestKey, populateFromHeader} from 'firefly/visualize/task/CreateTaskUtil.js'; const colorList= [ '#FF0000','#00FF00', '#0000FF', '#91D33D', @@ -29,7 +28,7 @@ const colorList= [ function watchForCompletedPlot(action, cancelSelf, params) { const {pvNewPlotInfoAry, plotId}= action.payload; - if (action.type===ImagePlotCntlr.PLOT_IMAGE_FAIL) { + if (action.type===PLOT_IMAGE_FAIL) { if (action.payload.plotId===plotId) cancelSelf(); return params; } @@ -66,7 +65,7 @@ export function plotImageMaskActionCreator(rawAction) { payload.lazyLoadPayload= {plotId,imageOverlayId}; } - dispatcher({type:ImagePlotCntlr.PLOT_MASK_START, payload}); + dispatcher({type:PLOT_MASK_START, payload}); if (!lazyLoad && !plot) { vr= getStore()[IMAGE_PLOT_KEY]; @@ -75,7 +74,7 @@ export function plotImageMaskActionCreator(rawAction) { dispatchAddActionWatcher( { callback: watchForCompletedPlot, params: {plotId, opv}, - actions: [ImagePlotCntlr.PLOT_IMAGE, ImagePlotCntlr.PLOT_IMAGE_FAIL] + actions: [PLOT_IMAGE, PLOT_IMAGE_FAIL] } ); } @@ -89,7 +88,7 @@ export function plotImageMaskActionCreator(rawAction) { export function plotImageMaskLazyActionCreator(rawAction) { return (dispatcher,getStore) => { const {plotId,imageOverlayId }= rawAction.payload; - dispatcher( { type: ImagePlotCntlr.OVERLAY_PLOT_CHANGE_ATTRIBUTES, + dispatcher( { type: OVERLAY_PLOT_CHANGE_ATTRIBUTES, payload: { plotId,imageOverlayId, attributes:{visible:true}} }); const vr= getStore()[IMAGE_PLOT_KEY]; const opv= getOverlayById(getPlotViewById(vr, plotId), imageOverlayId); @@ -196,7 +195,7 @@ function processMaskSuccessResponse(dispatcher, payload, result) { const request0= plotState.getWebPlotRequest(); const resultPayload= {...payload}; - const pv= getPlotViewById(visRoot(),payload.plotId); + const {pv}= currentP(payload.plotId); const cubeIndex= convertImageIdxToHDU(pv,pv.primeIdx).cubeIdx; const plots= PlotCreate.map( (pc,idx) => { const plot=WebPlot.makeWebPlotData({plotId:imageOverlayId, wpInit:pc, asOverlay:true, cubeCtx:cubeCtx[idx], request0}); @@ -207,7 +206,7 @@ function processMaskSuccessResponse(dispatcher, payload, result) { resultPayload.cube=PlotCreate.length>1; resultPayload.primeIdx= 0; resultPayload.plot=resultPayload.plots[cubeIndex]; - dispatcher({type: ImagePlotCntlr.PLOT_MASK, payload: resultPayload}); + dispatcher({type: PLOT_MASK, payload: resultPayload}); } else { const resultPayload= Object.assign({},payload); @@ -215,7 +214,7 @@ function processMaskSuccessResponse(dispatcher, payload, result) { resultPayload.briefDescription= result.briefFailReason; resultPayload.description= 'Failed- ' + result.userFailReason; resultPayload.detailFailReason= result.detailFailReason; - dispatcher( { type: ImagePlotCntlr.PLOT_MASK_FAIL, payload:resultPayload} ); + dispatcher( { type: PLOT_MASK_FAIL, payload:resultPayload} ); } } diff --git a/src/firefly/js/visualize/task/LSSTFootprintTask.js b/src/firefly/js/visualize/task/LSSTFootprintTask.js index 262a3d9aae..153cc59c3d 100644 --- a/src/firefly/js/visualize/task/LSSTFootprintTask.js +++ b/src/firefly/js/visualize/task/LSSTFootprintTask.js @@ -4,15 +4,18 @@ import {get, isArray, isUndefined, isEmpty} from 'lodash'; import {findTableCenterColumns} from '../../voAnalyzer/TableAnalysis.js'; import {Style} from '../draw/DrawingDef.js'; -import {primePlot, getDrawLayerById} from '../PlotViewUtil.js'; -import {dispatchCreateDrawLayer, getDlAry, dispatchAttachLayerToPlot, dispatchModifyCustomField, - dispatchDestroyDrawLayer} from '../DrawLayerCntlr.js'; +import { + dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDestroyDrawLayer, dispatchModifyCustomField +} from '../DrawLayerDispatch'; +import {getDrawLayerById, currentP} from '../PlotViewUtil.js'; import {clone} from '../../util/WebUtil.js'; import {ImageLineBasedObj} from '../draw/ImageLineBasedObj.js'; -import ImagePlotCntlr, {visRoot, dispatchPlotImage} from '../ImagePlotCntlr.js'; +import {dispatchPlotImage} from '../ImagePlotDispatch'; import {makeTblRequest, cloneRequest, MAX_ROW} from '../../tables/TableRequestUtil.js'; import {dispatchAddActionWatcher} from '../../core/MasterSaga.js'; -import {getAViewFromMultiView, getMultiViewRoot, IMAGE} from '../MultiViewCntlr.js'; +import {getAViewFromMultiView, getMultiViewRoot} from '../MultiViewCntlr.js'; +import {IMAGE, PLOT_IMAGE} from '../VisConst'; +import {getDlAry} from '../VisStoreRoots'; import WebPlotRequest from '../WebPlotRequest.js'; import {dispatchTableSearch, dispatchTableRemove, dispatchTableUpdate, TABLE_LOADED, TABLE_SELECT, TABLE_HIGHLIGHT, TABLE_UPDATE, TABLE_REMOVE, TABLE_SORT, TABLE_FILTER} from '../../tables/TablesCntlr.js'; @@ -86,12 +89,7 @@ export function imageLineBasedfootprintActionCreator(action) { } if (!imagePlotId) { - if (footprintImageFile) { - imagePlotId = getFileNameFromPath(footprintImageFile); // create a new plot - } else { - const pv = primePlot(visRoot()); // check the active plot - imagePlotId = pv ? pv.plotId : null; - } + imagePlotId = footprintImageFile ? getFileNameFromPath(footprintImageFile) : currentP().plotId; } if (!imagePlotId) { @@ -125,7 +123,7 @@ export function imageLineBasedfootprintActionCreator(action) { if (footprintImageFile) { - dispatchAddActionWatcher({actions: [ImagePlotCntlr.PLOT_IMAGE], callback: footprintImageWatcher}); + dispatchAddActionWatcher({actions: [PLOT_IMAGE], callback: footprintImageWatcher}); loadFootprintImage(footprintImageFile, imagePlotId); } else if (footprintFile) { getFootprintData(footprintFile, imagePlotId, tbl_index); diff --git a/src/firefly/js/visualize/task/PlotAdminTask.js b/src/firefly/js/visualize/task/PlotAdminTask.js index cd73b478a2..57a9a8ee94 100644 --- a/src/firefly/js/visualize/task/PlotAdminTask.js +++ b/src/firefly/js/visualize/task/PlotAdminTask.js @@ -3,23 +3,24 @@ */ import {get} from 'lodash'; -import ImagePlotCntlr, {dispatchChangeActivePlotView, dispatchPlotHiPS, - visRoot, IMAGE_PLOT_KEY, dispatchRotate, dispatchFlip, dispatchPlotImage, - ActionScope, dispatchWcsMatch } from '../ImagePlotCntlr.js'; -import {getExpandedViewerItemIds, findViewerWithItemId, - getMultiViewRoot, IMAGE} from '../MultiViewCntlr.js'; -import PointSelection from '../../drawingLayers/PointSelection.js'; import { - dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDestroyDrawLayer, - dispatchDetachLayerFromPlot, DRAWING_LAYER_KEY -} from '../DrawLayerCntlr.js'; + dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDestroyDrawLayer, dispatchDetachLayerFromPlot +} from '../DrawLayerDispatch'; +import { + dispatchChangeActivePlotView, dispatchFlip, dispatchPlotHiPS, dispatchPlotImage, dispatchRotate, dispatchWcsMatch +} from '../ImagePlotDispatch'; +import {getExpandedViewerItemIds, findViewerWithItemId, getMultiViewRoot} from '../MultiViewCntlr.js'; +import PointSelection from '../../drawingLayers/PointSelection.js'; import { getPlotViewById, applyToOnePvOrAll, isDrawLayerAttached, primePlot, getDrawLayerByType, removeRawDataByPlotView } from '../PlotViewUtil.js'; import {isImage} from '../WebPlot.js'; import {RotateType} from '../PlotState.js'; import {detachSelectAreaRelatedLayers} from '../ui/SelectAreaUIComponents.jsx'; import {getAppOptions} from '../../core/AppDataCntlr'; -import {WcsMatchType} from '../ImagePlotCntlr'; +import { + ActionScope, DELETE_PLOT_VIEW, DRAWING_LAYER_KEY, IMAGE, IMAGE_PLOT_KEY, WCS_MATCH, WcsMatchType +} from '../VisConst'; +import {visRoot} from '../VisStoreRoots'; import {hasOverlayColorLock, findPlotGroup } from '../PlotViewUtil'; import {onPlotComplete} from '../PlotCompleteMonitor'; @@ -173,8 +174,8 @@ export function deletePlotViewActionCreator(rawAction) { removeRawDataByPlotView(getPlotViewById(vr,plotId)); if (vr.wcsMatchType && !payload.holdWcsMatch) { - dispatcher({ type: ImagePlotCntlr.WCS_MATCH, payload: {wcsMatchType:false} }); + dispatcher({ type: WCS_MATCH, payload: {wcsMatchType:false} }); } - dispatcher({type:ImagePlotCntlr.DELETE_PLOT_VIEW, payload: {...payload, viewerId}}); + dispatcher({type:DELETE_PLOT_VIEW, payload: {...payload, viewerId}}); }; } diff --git a/src/firefly/js/visualize/task/PlotChangeTask.js b/src/firefly/js/visualize/task/PlotChangeTask.js index 63edc672f0..91a9b54641 100644 --- a/src/firefly/js/visualize/task/PlotChangeTask.js +++ b/src/firefly/js/visualize/task/PlotChangeTask.js @@ -4,19 +4,15 @@ import {isNumber, isArray, set} from 'lodash'; import {logger} from '../../util/Logger.js'; -import ImagePlotCntlr, { - IMAGE_PLOT_KEY, dispatchWcsMatch, ActionScope, visRoot, dispatchMarkOutOfMemory -} from '../ImagePlotCntlr.js'; +import {dispatchMarkOutOfMemory, dispatchWcsMatch} from '../ImagePlotDispatch'; import { - primePlot, - getPlotViewById, - operateOnOthersInOverlayColorGroup, - getPlotStateAry, - isThreeColor, - findPlot, - getOverlayById + primePlot, getPlotViewById, operateOnOthersInOverlayColorGroup, getPlotStateAry, + isThreeColor, findPlot, getOverlayById, currentP, } from '../PlotViewUtil.js'; import {callCrop} from '../../rpc/PlotServicesJson.js'; +import { + ActionScope, ANY_REPLOT, COLOR_CHANGE, CROP, CROP_FAIL, CROP_START, IMAGE_PLOT_KEY, STRETCH_CHANGE +} from '../VisConst'; import {WebPlotResult} from '../WebPlotResult.js'; import {isHiPS, isImage, WebPlot} from '../WebPlot.js'; import {locateOtherIfMatched} from './WcsMatchTask'; @@ -37,7 +33,7 @@ import {parseAnyPt} from 'firefly/visualize/Point'; export function requestLocalDataActionCreator(rawAction) { return (dispatcher) => { const {plotId, plotImageId, dataRequested= true, imageOverlayId}=rawAction.payload; - const pv= getPlotViewById(visRoot(),plotId); + const {pv}= currentP(plotId); const plot= imageOverlayId ? getOverlayById(pv,imageOverlayId)?.plot : findPlot(pv,plotImageId); if (!isImage(plot)) return; if (dataRequested===false) { @@ -105,10 +101,10 @@ function colorChangeImage(store,dispatcher,payload) { if (abort) return; const {bias, contrast, colorTableId, nanPixelColor, bandUse}= colorChangeResults; dispatcher( { - type: ImagePlotCntlr.COLOR_CHANGE, + type: COLOR_CHANGE, payload: { plotId, bias, contrast, colorTableId, nanPixelColor, ...bandUse } }); - dispatcher( { type: ImagePlotCntlr.ANY_REPLOT, payload:{plotIdAry:[plotId]}} ); + dispatcher( { type: ANY_REPLOT, payload:{plotIdAry:[plotId]}} ); }; @@ -150,9 +146,9 @@ function colorChangeHiPS(store, dispatcher, payload) { const doDispatch= (plotId) => { dispatcher( { - type:ImagePlotCntlr.COLOR_CHANGE, + type:COLOR_CHANGE, payload: { plotId, colorTableId: cbarId, bias, contrast}}); - dispatcher( { type: ImagePlotCntlr.ANY_REPLOT, payload:{plotIdAry:[plotId]}} ); + dispatcher( { type: ANY_REPLOT, payload:{plotIdAry:[plotId]}} ); }; doDispatch(plotId,plot.plotState); @@ -239,15 +235,14 @@ export function cropActionCreator(rawAction) { function doCrop(dispatcher,pv,imagePt1, imagePt2, cropMultiAll, originalWcsMatchType) { const makeSuccAction= (plotId, plotAry, overlayPlotViews) => ({ - type: ImagePlotCntlr.CROP, - payload: {pvNewPlotInfoAry: [{plotId, plotAry, overlayPlotViews}]} + type: CROP, payload: {pvNewPlotInfoAry: [{plotId, plotAry, overlayPlotViews}]} }); - const makeFailAction= (plotId) => ({ type: ImagePlotCntlr.CROP_FAIL, + const makeFailAction= (plotId) => ({ type: CROP_FAIL, payload: {plotId, message: 'Crop Failed', error: Error('crop: payload failed')} }); - dispatcher( { type: ImagePlotCntlr.CROP_START, payload: {plotId:pv.plotId, message:'Cropping...'} } ); + dispatcher( { type: CROP_START, payload: {plotId:pv.plotId, message:'Cropping...'} } ); callCrop(getPlotStateAry(pv), imagePt1, imagePt2, cropMultiAll) .then( (wpResult) => { processPlotReplace(dispatcher,wpResult,pv,makeSuccAction, makeFailAction); @@ -267,10 +262,10 @@ function doStretchDispatch(dispatcher,getState, store,plotId,stretchData) { stretchData.forEach( (sd) => plotState.setRangeValues(Band.get(sd.band),RangeValues.parse(sd.rv))); dispatcher( { - type: ImagePlotCntlr.STRETCH_CHANGE, + type: STRETCH_CHANGE, payload: { plotId, primaryStateJson : PlotState.convertToJSON(plotState) } }); - dispatcher( { type: ImagePlotCntlr.ANY_REPLOT, payload:{plotIdAry:[plotId]}} ); + dispatcher( { type: ANY_REPLOT, payload:{plotIdAry:[plotId]}} ); } @@ -308,7 +303,7 @@ function processPlotReplace(dispatcher, result, pv, makeSuccessAction, makeFailA }); dispatcher( makeSuccessAction(pv.plotId, plotAry, overlayPlotViews)); - dispatcher({type: ImagePlotCntlr.ANY_REPLOT, payload: {plotIdAry: [pv.plotId]}}); + dispatcher({type: ANY_REPLOT, payload: {plotIdAry: [pv.plotId]}}); successSent = true; } diff --git a/src/firefly/js/visualize/task/PlotHipsTask.js b/src/firefly/js/visualize/task/PlotHipsTask.js index a6c01c1563..362428dc53 100644 --- a/src/firefly/js/visualize/task/PlotHipsTask.js +++ b/src/firefly/js/visualize/task/PlotHipsTask.js @@ -5,51 +5,31 @@ import {isEmpty, isString} from 'lodash'; import {getHttpErrorMessage} from '../../util/HttpErrorMessage.js'; import {CoordinateSys} from '../CoordSys.js'; -import ImagePlotCntlr, { - dispatchChangeCenterOfProjection, - dispatchPlotHiPS, - dispatchChangeHiPS, - dispatchAbortHiPS, - dispatchPlotImage, - dispatchPlotProgressUpdate, - dispatchZoom, - IMAGE_PLOT_KEY, - visRoot, - WcsMatchType, - makeUniqueRequestKey -} from '../ImagePlotCntlr.js'; +import { + dispatchAttachLayerToPlot, dispatchChangeVisibility, dispatchCreateDrawLayer, dispatchDetachLayerFromPlot +} from '../DrawLayerDispatch'; +import { + dispatchAbortHiPS, dispatchChangeCenterOfProjection, dispatchChangeHiPS, dispatchPlotHiPS, dispatchPlotImage, + dispatchPlotProgressUpdate, dispatchZoom +} from '../ImagePlotDispatch'; +import { + ANY_REPLOT, CHANGE_HIPS, IMAGE_PLOT_KEY, PLOT_HIPS, PLOT_HIPS_FAIL, PLOT_IMAGE_START, + UPDATE_VIEW_SIZE, UserZoomTypes, WcsMatchType, ZoomType +} from '../VisConst'; +import {dlRoot, getDlAry, visRoot} from '../VisStoreRoots'; import {makeWorldPt} from '../Point.js'; -import {UserZoomTypes} from '../ZoomUtil.js'; import {WebPlot, isHiPS, isImage, isBlankHiPSURL} from '../WebPlot.js'; import {PlotAttribute} from '../PlotAttribute.js'; import {getStatusFromFetchError} from '../../util/WebUtil.js'; import { - findCurrentCenterPoint, - getCenterOfProjection, - getCorners, - getDrawLayerByType, - getDrawLayersByType, - getFoV, - getPlotViewById, - primePlot, + findCurrentCenterPoint, getCenterOfProjection, getCorners, getDrawLayerByType, getDrawLayersByType, + getFoV, getPlotViewById, primePlot, } from '../PlotViewUtil.js'; import {dispatchAddActionWatcher} from '../../core/MasterSaga.js'; import { - getHiPSZoomLevelForFOV, - getPointMaxSide, - getPropertyItem, - makeHiPSPropertiesUrl, - resolveHiPSConstant + getHiPSZoomLevelForFOV, getPointMaxSide, getPropertyItem, makeHiPSPropertiesUrl, resolveHiPSConstant } from '../HiPSUtil.js'; -import {ZoomType} from '../ZoomType.js'; import {CCUtil} from '../CsysConverter.js'; -import { - dispatchAttachLayerToPlot, dispatchChangeVisibility, - dispatchCreateDrawLayer, - dispatchDetachLayerFromPlot, - dlRoot, - getDlAry -} from '../DrawLayerCntlr.js'; import ImageOutline from '../../drawingLayers/ImageOutline.js'; import Artifact from '../../drawingLayers/Artifact.js'; import HiPSGrid from '../../drawingLayers/HiPSGrid.js'; @@ -67,7 +47,7 @@ import { clearActiveRequest, getActiveRequestKey, setActiveRequestKey } from 'firefly/visualize/task/ActivePlottingTask.js'; import { - addDrawLayers, determineViewerId, ensureWPR, getHipsImageConversion + addDrawLayers, determineViewerId, ensureWPR, getHipsImageConversion, makeUniqueRequestKey } from 'firefly/visualize/task/CreateTaskUtil.js'; const PROXY= true; @@ -221,7 +201,7 @@ async function makeHiPSPlot(rawAction, dispatcher) { const requestKey= makeUniqueRequestKey('plotRequestKey'); setActiveRequestKey(plotId,requestKey); - const hipsFail= (msg) => dispatcher( { type: ImagePlotCntlr.PLOT_HIPS_FAIL, + const hipsFail= (msg) => dispatcher( { type: PLOT_HIPS_FAIL, payload:{ description: `HiPS display failed: ${msg}`, plotId, wpRequest } }); @@ -233,7 +213,7 @@ async function makeHiPSPlot(rawAction, dispatcher) { // console.log('hips plot expired or aborted'); return; } - dispatcher( { type: ImagePlotCntlr.PLOT_IMAGE_START,payload:newPayload} ); + dispatcher( { type: PLOT_IMAGE_START,payload:newPayload} ); if (!resolvedHipsRootUrl) { hipsFail('Empty URL'); return; @@ -268,12 +248,12 @@ async function makeHiPSPlot(rawAction, dispatcher) { await getGpuJs(); // make sure the GPU code is loaded up front createHiPSGridLayer(); dispatchAddActionWatcher({ - actions:[ImagePlotCntlr.PLOT_HIPS, ImagePlotCntlr.UPDATE_VIEW_SIZE], + actions:[PLOT_HIPS, UPDATE_VIEW_SIZE], callback:watchForHiPSViewDim, params:{plotId}} ); const pvNewPlotInfoAry= [ {plotId, plotAry: [plot]} ]; - dispatcher( { type: ImagePlotCntlr.PLOT_HIPS, payload: {...newPayload, plot,pvNewPlotInfoAry }}); + dispatcher( { type: PLOT_HIPS, payload: {...newPayload, plot,pvNewPlotInfoAry }}); } catch (error) { const status= propertiesUrlForError ? getStatusFromFetchError(error.message) : 0; const msg= status ? `status: ${status} (${getHttpErrorMessage(status)}), url: ${propertiesUrlForError}` : error.message; @@ -359,9 +339,9 @@ async function doHiPSChange(rawAction, dispatcher, getState) { if (!hipsUrlRoot) { // only change to some attributes, we are not replacing the HiPS source const newPayload= {...payload, blank}; - dispatcher( { type: ImagePlotCntlr.CHANGE_HIPS, payload:newPayload }); + dispatcher( { type: CHANGE_HIPS, payload:newPayload }); locateOtherIfMatched(visRoot(),plotId); - dispatcher( { type: ImagePlotCntlr.ANY_REPLOT, payload:newPayload }); + dispatcher( { type: ANY_REPLOT, payload:newPayload }); return; } @@ -397,12 +377,12 @@ async function doHiPSChange(rawAction, dispatcher, getState) { dispatcher( { - type: ImagePlotCntlr.CHANGE_HIPS, + type: CHANGE_HIPS, payload: {...payload, hipsUrlRoot:resolvedHipsRootUrl, hipsProperties, coordSys: coordSys? coordSys : plot.imageCoordSys, blank}, }); initCorrectCoordinateSys(getPlotViewById(visRoot(), plotId)); locateOtherIfMatched(visRoot(),plotId); - dispatcher({type: ImagePlotCntlr.ANY_REPLOT, payload}); + dispatcher({type: ANY_REPLOT, payload}); } catch (error) { console.log(error); hipsChangeFailP(pv, error.message); diff --git a/src/firefly/js/visualize/task/PlotImageTask.js b/src/firefly/js/visualize/task/PlotImageTask.js index b0a7fbd620..259eb32970 100644 --- a/src/firefly/js/visualize/task/PlotImageTask.js +++ b/src/firefly/js/visualize/task/PlotImageTask.js @@ -4,10 +4,14 @@ import {flatten, isArray, isEmpty, uniqBy} from 'lodash'; import {getExtName, getExtType} from '../FitsHeaderUtil.js'; +import {dispatchPlotProgressUpdate, dispatchRecenter, dispatchWcsMatch} from '../ImagePlotDispatch'; +import { + ANY_REPLOT, EXPANDED_MODE_RESERVED, IMAGE, IMAGE_PLOT_KEY, PLOT_IMAGE, PLOT_IMAGE_FAIL, + PLOT_IMAGE_START, WCS_MATCH +} from '../VisConst'; +import {visRoot} from '../VisStoreRoots'; import {getCenterPtOfPlot} from '../WebPlotAnalysis'; -import {DEFAULT_THUMBNAIL_SIZE, WebPlotRequest, WPConst} from '../WebPlotRequest.js'; -import ImagePlotCntlr, {IMAGE_PLOT_KEY, makeUniqueRequestKey, visRoot, - dispatchPlotProgressUpdate, dispatchRecenter, dispatchWcsMatch} from '../ImagePlotCntlr.js'; +import {WebPlotRequest} from '../WebPlotRequest.js'; import {dispatchActiveTarget, getActiveTarget} from '../../core/AppDataCntlr.js'; import {RDConst, WebPlot} from '../WebPlot.js'; import {PlotAttribute} from '../PlotAttribute'; @@ -15,7 +19,7 @@ import {PlotState} from '../PlotState.js'; import {Band} from '../Band.js'; import {PlotPref} from '../PlotPref.js'; import {makePostPlotTitle} from '../reducer/PlotTitle.js'; -import {dispatchAddViewerItems, EXPANDED_MODE_RESERVED, IMAGE} from '../MultiViewCntlr.js'; +import {dispatchAddViewerItems } from '../MultiViewCntlr.js'; import {getPlotViewById, getPlotViewIdListInOverlayGroup, hasWCSProjection} from '../PlotViewUtil.js'; import {enableMatchingRelatedData} from '../RelatedDataUtil.js'; import {doFetchTable} from '../../tables/TableUtil.js'; @@ -23,7 +27,7 @@ import {callGetWebPlot, callGetWebPlot3Color, callGetWebPlotGroup} from '../../r import {onViewDimDefined} from '../PlotCompleteMonitor.js'; import {getActiveRequestKey} from './ActivePlottingTask.js'; import { - addDrawLayers, makeCubeCtxAry, makeGroupPayload, makeSinglePlotPayload, populateFromHeader + addDrawLayers, makeCubeCtxAry, makeGroupPayload, makeSinglePlotPayload, makeUniqueRequestKey, populateFromHeader } from './CreateTaskUtil.js'; import {logger} from '../../util/Logger.js'; @@ -45,9 +49,9 @@ export function makePlotImageAction(rawAction) { vr= getState()[IMAGE_PLOT_KEY]; if (vr.wcsMatchType && !rawAction.payload.holdWcsMatch) { - dispatcher({ type: ImagePlotCntlr.WCS_MATCH, payload: {wcsMatchType:false} }); + dispatcher({ type: WCS_MATCH, payload: {wcsMatchType:false} }); } - const action= { type: ImagePlotCntlr.PLOT_IMAGE_START,payload}; + const action= { type: PLOT_IMAGE_START,payload}; dispatcher(action); wpRequestAry ? executeGroupSearch(action, dispatcher) : executeSingleSearch(action,dispatcher); }; @@ -71,7 +75,7 @@ async function executeSingleSearch(rawAction, dispatcher) { const wpResult= threeColor ? await callGetWebPlot3Color(redReq,greenReq,blueReq) : await callGetWebPlot(wpRequest); processPlotImageSuccessResponse(dispatcher,rawAction.payload,wpResult); } catch (e) { - dispatcher( { type: ImagePlotCntlr.PLOT_IMAGE_FAIL, payload: {plotId, error:e} } ); + dispatcher( { type: PLOT_IMAGE_FAIL, payload: {plotId, error:e} } ); logger.error(`plot error, ImagePlotter, plotId: ${plotId}`, e); } } @@ -89,7 +93,7 @@ async function executeGroupSearch(rawAction, dispatcher) { processPlotImageSuccessResponse(dispatcher,rawAction.payload,wpResult); } catch (e) { const plotIdAry= wpRequestAry.map( (r) => r.getPlotId()).filter( (id) => id); - dispatcher( { type: ImagePlotCntlr.PLOT_IMAGE_FAIL, payload: {plotIdAry, wpRequestAry, error:e} } ); + dispatcher( { type: PLOT_IMAGE_FAIL, payload: {plotIdAry, wpRequestAry, error:e} } ); logger.error('plot group error', e); } } @@ -208,10 +212,10 @@ function processSuccessResult(dispatcher, payload, successAry) { realPlotAry.forEach((p) => p.tileData = undefined ); }); - dispatcher({type: ImagePlotCntlr.PLOT_IMAGE, payload: resultPayload}); + dispatcher({type: PLOT_IMAGE, payload: resultPayload}); const plotIdAry = pvNewPlotInfoAry.map((info) => info.plotId); const filteredPlotIdAry= plotIdAry.filter( (id) => getPlotViewById(visRoot(),id)); - dispatcher({type: ImagePlotCntlr.ANY_REPLOT, payload: {plotIdAry:filteredPlotIdAry}}); + dispatcher({type: ANY_REPLOT, payload: {plotIdAry:filteredPlotIdAry}}); matchAndActivateOverlayPlotViewsByGroup(filteredPlotIdAry); @@ -245,7 +249,7 @@ function processFailResult(failAry, originalPayload, dispatcher) { ...originalPayload, plotId, detailFailReason, briefDescription: briefFailReason, description: 'Failed- ' + userFailReason}; - dispatcher( { type: ImagePlotCntlr.PLOT_IMAGE_FAIL, payload} ); + dispatcher( { type: PLOT_IMAGE_FAIL, payload} ); } }); } diff --git a/src/firefly/js/visualize/task/WcsMatchTask.js b/src/firefly/js/visualize/task/WcsMatchTask.js index 187eaccae8..dcf8305951 100644 --- a/src/firefly/js/visualize/task/WcsMatchTask.js +++ b/src/firefly/js/visualize/task/WcsMatchTask.js @@ -3,11 +3,15 @@ */ import {isEmpty} from 'lodash'; -import ImagePlotCntlr, { - ActionScope, dispatchAttributeChange, dispatchChangeCenterOfProjection, dispatchChangeHiPS, dispatchFlip, - dispatchPositionLocking, dispatchRecenter, dispatchRotate, dispatchUpdateViewSize, dispatchZoom, IMAGE_PLOT_KEY, - visRoot, WcsMatchType -} from '../ImagePlotCntlr.js'; +import {dispatchAttachLayerToPlot, dispatchCreateDrawLayer} from '../DrawLayerDispatch'; +import { + dispatchAttributeChange, dispatchChangeCenterOfProjection, dispatchChangeHiPS, dispatchFlip, dispatchPositionLocking, + dispatchRecenter, dispatchRotate, dispatchUpdateViewSize, dispatchZoom +} from '../ImagePlotDispatch'; +import { + ActionScope, FullType, IMAGE_PLOT_KEY, PLOT_IMAGE, PLOT_IMAGE_FAIL, UserZoomTypes, WCS_MATCH, WcsMatchType +} from '../VisConst'; +import {dlRoot, visRoot} from '../VisStoreRoots'; import {isEastLeftOfNorth, isPlotRotatedNorth} from '../WebPlotAnalysis'; import { applyToOnePvOrAll, findCurrentCenterPoint, getCenterOfProjection, getCorners, getDrawLayerByType, @@ -16,14 +20,11 @@ import { } from '../PlotViewUtil.js'; import {isHiPS, isImage} from '../WebPlot.js'; import {PlotAttribute} from '../PlotAttribute'; -import { - FullType, getArcSecPerPix, getEstimatedFullZoomFactor, getZoomLevelForScale, UserZoomTypes -} from '../ZoomUtil.js'; +import {getArcSecPerPix, getEstimatedFullZoomFactor, getZoomLevelForScale} from '../ZoomUtil.js'; import {RotateType} from '../PlotState.js'; import {CCUtil} from '../CsysConverter.js'; import {makeScreenPt, pointEquals} from '../Point.js'; import CoordinateSys from '../CoordSys'; -import {dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dlRoot} from '../DrawLayerCntlr'; import ImageOutline from '../../drawingLayers/ImageOutline'; import {dispatchAddActionWatcher} from '../../core/MasterSaga'; @@ -32,7 +33,7 @@ function watchForCompletedPlot(action, cancelSelf, params, dispatch, getState) { const {plotId, masterPlotId, wcsMatchType}= params; - if (action.type===ImagePlotCntlr.PLOT_IMAGE_FAIL) { + if (action.type===PLOT_IMAGE_FAIL) { if (action.payload.plotId===plotId) cancelSelf(); return params; } @@ -66,7 +67,7 @@ export function wcsMatchActionCreator(action) { if (!plotId && lockMatch) { dispatchPositionLocking(undefined, lockMatch); //TODO: - if (lockMatch) dispatcher({ type: ImagePlotCntlr.WCS_MATCH, payload: {wcsMatchType:matchType} }); + if (lockMatch) dispatcher({ type: WCS_MATCH, payload: {wcsMatchType:matchType} }); return; } let masterPv= getPlotViewById(visRoot, plotId); @@ -78,7 +79,7 @@ export function wcsMatchActionCreator(action) { if (image && lockMatch && (!width || !height)) { dispatcher({ - type: ImagePlotCntlr.WCS_MATCH, + type: WCS_MATCH, payload: {wcsMatchCenterWP:null,wcsMatchType:matchType,mpwWcsPrimId:plotId, lockMatch} }); applyToOnePvOrAll(true, visRoot.plotViewAry, masterPv.plotId, false, @@ -87,7 +88,7 @@ export function wcsMatchActionCreator(action) { dispatchAddActionWatcher( { callback: watchForCompletedPlot, params: {plotId:pv.plotId, masterPlotId:plotId, wcsMatchType:matchType}, - actions: [ImagePlotCntlr.PLOT_IMAGE, ImagePlotCntlr.PLOT_IMAGE_FAIL] + actions: [PLOT_IMAGE, PLOT_IMAGE_FAIL] } ); } } @@ -101,7 +102,7 @@ export function wcsMatchActionCreator(action) { const wcsMatchCenterWP= findWcsMatchPoint(masterPv, plotId, matchType); dispatcher({ - type: ImagePlotCntlr.WCS_MATCH, + type: WCS_MATCH, payload: {wcsMatchCenterWP,wcsMatchType:matchType,mpwWcsPrimId:masterPv.plotId} }); @@ -160,7 +161,7 @@ export function wcsMatchActionCreator(action) { if (!lockMatch) { dispatchPositionLocking(masterPv.plotId,false); dispatcher({ - type: ImagePlotCntlr.WCS_MATCH, + type: WCS_MATCH, payload: {wcsMatchCenterWP,wcsMatchType:false,mpwWcsPrimId:masterPv.plotId} }); } diff --git a/src/firefly/js/visualize/task/ZoomTask.js b/src/firefly/js/visualize/task/ZoomTask.js index 274564828c..f8a89536f9 100644 --- a/src/firefly/js/visualize/task/ZoomTask.js +++ b/src/firefly/js/visualize/task/ZoomTask.js @@ -2,11 +2,14 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ import {updateStretchDataAfterZoom} from '../rawData/RawDataOps.js'; -import {UserZoomTypes, getArcSecPerPix, getEstimatedFullZoomFactor, - getNextZoomLevel, getZoomLevelForScale, FullType} from '../ZoomUtil.js'; +import {dispatchChangeCenterOfProjection, dispatchRecenter, dispatchUpdateViewSize} from '../ImagePlotDispatch'; +import { + ActionScope, ANY_REPLOT, FullType, IMAGE_PLOT_KEY, UserZoomTypes, WcsMatchType, ZOOM_HIPS, ZOOM_IMAGE +} from '../VisConst'; +import { + getArcSecPerPix, getEstimatedFullZoomFactor, getNextZoomLevel, getZoomLevelForScale +} from '../ZoomUtil.js'; import {isImage, isHiPS} from '../WebPlot.js'; -import ImagePlotCntlr, { ActionScope, IMAGE_PLOT_KEY, WcsMatchType, - dispatchUpdateViewSize, dispatchRecenter, dispatchChangeCenterOfProjection } from '../ImagePlotCntlr.js'; import { getPlotViewById, primePlot, operateOnOthersInPositionGroup, applyToOnePvOrAll} from '../PlotViewUtil.js'; import {isImageViewerSingleLayout, getMultiViewRoot} from '../MultiViewCntlr.js'; import {doHiPSImageConversionIfNecessary} from './PlotHipsTask.js'; @@ -183,7 +186,7 @@ function doZoom(dispatcher,plot,zoomLevel, zoomLockingEnabled, userZoomType,devi function processHiPSZoom(dispatcher, plot, zoomLevel, userZoomType, zoomLockingEnabled, devicePt, getState) { dispatcher({ - type: ImagePlotCntlr.ZOOM_HIPS, + type: ZOOM_HIPS, payload: {plotId:plot.plotId, zoomLevel, zoomLockingEnabled, userZoomType, devicePt} }); const {plotId}= plot; @@ -196,14 +199,14 @@ function processHiPSZoom(dispatcher, plot, zoomLevel, userZoomType, zoomLockingE centerProjPt && dispatchChangeCenterOfProjection({plotId, centerProjPt}); } } - dispatcher({type: ImagePlotCntlr.ANY_REPLOT, payload: {plotId}}); + dispatcher({type: ANY_REPLOT, payload: {plotId}}); } function processFitsImageZoom(dispatcher, plot, zoomLevel, userZoomType, zoomLockingEnabled, devicePt) { const {plotId}= plot; dispatcher( { - type: ImagePlotCntlr.ZOOM_IMAGE, + type: ZOOM_IMAGE, payload: { zoomLevel, zoomLockingEnabled,userZoomType, devicePt, plotId, primaryStateJson:undefined}}); - dispatcher( { type: ImagePlotCntlr.ANY_REPLOT, payload:{plotIdAry:[plotId]}} ); + dispatcher( { type: ANY_REPLOT, payload:{plotIdAry:[plotId]}} ); void updateStretchDataAfterZoom(plotId, dispatcher); } diff --git a/src/firefly/js/visualize/ui/ApiFullImageDisplay.jsx b/src/firefly/js/visualize/ui/ApiFullImageDisplay.jsx index 28fcab9813..2299c84b6b 100644 --- a/src/firefly/js/visualize/ui/ApiFullImageDisplay.jsx +++ b/src/firefly/js/visualize/ui/ApiFullImageDisplay.jsx @@ -7,14 +7,13 @@ import React, {memo} from 'react'; import {string} from 'prop-types'; import {MultiViewStandardToolbar} from './MultiViewStandardToolbar.jsx'; import {MultiImageViewer} from './MultiImageViewer.jsx'; -import {NewPlotMode} from '../MultiViewCntlr.js'; +import {NewPlotMode} from '../VisConst'; import {RenderTreeIdCtx} from '../../ui/RenderTreeIdCtx.jsx'; export const ApiFullImageDisplay= memo(({viewerId, renderTreeId}) => ( + border: '1px solid', borderColor: 'divider', borderRadius: '5px' }}> { dispatchForceFieldGroupReducer(groupKey); },[]); - useWatcher([ImagePlotCntlr.ANY_REPLOT, ImagePlotCntlr.CHANGE_ACTIVE_PLOT_VIEW], + useWatcher([ANY_REPLOT, CHANGE_ACTIVE_PLOT_VIEW], (action) => { dispatchForceFieldGroupReducer(groupKey, action); } @@ -326,7 +327,7 @@ function getReplotFunc(groupKey, band) { const request = getFieldGroupResults(groupKey); const serRv = makeSerializedRv(request); const stretchData = [{band: band.key, rv: serRv, bandVisible: true}]; - const pv = getActivePlotView(visRoot()); + const {pv} = currentP(); if (pv) dispatchStretchChange({plotId: pv.plotId, stretchData}); } }); diff --git a/src/firefly/js/visualize/ui/ColorDialog.jsx b/src/firefly/js/visualize/ui/ColorDialog.jsx index 579560bfb5..11173a867e 100644 --- a/src/firefly/js/visualize/ui/ColorDialog.jsx +++ b/src/firefly/js/visualize/ui/ColorDialog.jsx @@ -14,8 +14,9 @@ import FieldGroupUtils from '../../fieldGroup/FieldGroupUtils.js'; import {FieldGroup} from '../../ui/FieldGroup.jsx'; import {ColorBandPanel} from './ColorBandPanel.jsx'; import {ColorRGBHuePreservingPanel} from './ColorRGBHuePreservingPanel.jsx'; -import {dispatchStretchChange, visRoot} from '../ImagePlotCntlr.js'; -import {primePlot, getActivePlotView, isThreeColor, getPlotViewAry} from '../PlotViewUtil.js'; +import {dispatchStretchChange} from '../ImagePlotDispatch'; +import {visRoot} from '../VisStoreRoots'; +import {primePlot, isThreeColor, getPlotViewAry, currentP} from '../PlotViewUtil.js'; import { RangeValues, ZSCALE, STRETCH_ASINH}from '../RangeValues.js'; import HelpIcon from '../../ui/HelpIcon.jsx'; import {showInfoPopup} from '../../ui/PopupUtil.jsx'; @@ -46,7 +47,7 @@ export function showColorDialog(element) { function getStoreUpdate(oldS) { - const plot= primePlot(visRoot()); + const {plot}= currentP(); const fields= FieldGroupUtils.getGroupFields(NO_BAND_PANEL); const rFields= FieldGroupUtils.getGroupFields(RED_PANEL); const gFields= FieldGroupUtils.getGroupFields(GREEN_PANEL); @@ -230,7 +231,7 @@ function replotStandard(request) { // console.log(request); const serRv= makeSerializedRv(request); const stretchData= [{ band: Band.NO_BAND.key, rv: serRv, bandVisible: true }]; - const pv= getActivePlotView(visRoot()); + const {pv}= currentP(); if (pv) dispatchStretchChange({plotId:pv.plotId,stretchData}); } @@ -252,7 +253,7 @@ export function replot3ColorHuePreserving(request) { }); return {band, rv, bandVisible: true}; }); - const pv= getActivePlotView(visRoot()); + const {pv}= currentP(); if (pv) dispatchStretchChange({plotId:pv.plotId,stretchData}); } @@ -287,7 +288,7 @@ function replot3Color(redReq,greenReq,blueReq,activeTab, usedBands) { } } - const pv= getActivePlotView(visRoot()); + const {pv}= currentP(); if (pv) dispatchStretchChange({plotId:pv.plotId,stretchData}); } diff --git a/src/firefly/js/visualize/ui/ColorPanelReducer.js b/src/firefly/js/visualize/ui/ColorPanelReducer.js index 2ee1c293ee..dc10a10400 100644 --- a/src/firefly/js/visualize/ui/ColorPanelReducer.js +++ b/src/firefly/js/visualize/ui/ColorPanelReducer.js @@ -4,10 +4,8 @@ import Validate from '../../util/Validate.js'; import FieldGroupCntlr, {FORCE_FIELD_GROUP_REDUCER} from '../../fieldGroup/FieldGroupCntlr.js'; -import {Band} from '../Band'; -import ImagePlotCntlr from '../ImagePlotCntlr.js'; -import {visRoot} from '../ImagePlotCntlr.js'; -import {primePlot} from '../PlotViewUtil.js'; +import {ANY_REPLOT, CHANGE_ACTIVE_PLOT_VIEW} from '../VisConst'; +import {currentP} from '../PlotViewUtil.js'; import RangeValues, {STRETCH_LINEAR, STRETCH_ASINH, PERCENTAGE, ABSOLUTE, SIGMA, ZSCALE} from './../RangeValues.js'; @@ -30,7 +28,7 @@ export const NO_BAND_PANEL= 'nobandPanel'; export function colorPanelChange(band) { return (fields,action) => { if (!fields || !Object.keys(fields).length) fields= getFieldInit(); - const plot= primePlot(visRoot()); + const {plot}= currentP(); if (!plot || !plot.plotState.isBandUsed(band)) return fields; const plottedRV= plot.plotState.getRangeValues(band); @@ -61,9 +59,9 @@ function computeColorPanelState(fields, plottedRV, band, action) { if (!valid) return fields; return syncFields(fields,makeRangeValuesFromFields(fields)); - case ImagePlotCntlr.CHANGE_ACTIVE_PLOT_VIEW: + case CHANGE_ACTIVE_PLOT_VIEW: case FORCE_FIELD_GROUP_REDUCER: - case ImagePlotCntlr.ANY_REPLOT: + case ANY_REPLOT: if (!plottedRV) return fields; // no update if hue-preserving if ((plottedRV?.rgbPreserveHue ?? 0) > 0) return fields; @@ -376,7 +374,7 @@ export function rgbHuePreserveChange(bands) { return (fields,action) => { if (!fields || !Object.keys(fields).length) fields= getHuePreserveFieldInit(); - const plot= primePlot(visRoot()); + const {plot}= currentP(); if (!plot || bands.some((b) => !plot.plotState.isBandUsed(b))) return fields; const plottedRVAry= bands.map((b)=>plot.plotState.getRangeValues(b)); @@ -406,8 +404,8 @@ export function computeHuePreservePanelState(fields, plottedRVAry, bands, action return syncFieldsHuePreserve(fields,makeHuePreserveRangeValuesFromFields(fields)); case FORCE_FIELD_GROUP_REDUCER: - case ImagePlotCntlr.CHANGE_ACTIVE_PLOT_VIEW: - case ImagePlotCntlr.ANY_REPLOT: + case CHANGE_ACTIVE_PLOT_VIEW: + case ANY_REPLOT: if (plottedRVAry.some((rv)=>!rv)) return fields; const newFields = updateHuePreserveFieldsFromRangeValues(fields,plottedRVAry); return syncFieldsHuePreserve(newFields,plottedRVAry); diff --git a/src/firefly/js/visualize/ui/ColorRGBHuePreservingPanel.jsx b/src/firefly/js/visualize/ui/ColorRGBHuePreservingPanel.jsx index 73fbe2485d..81e244143e 100644 --- a/src/firefly/js/visualize/ui/ColorRGBHuePreservingPanel.jsx +++ b/src/firefly/js/visualize/ui/ColorRGBHuePreservingPanel.jsx @@ -1,12 +1,11 @@ import {Stack, Typography} from '@mui/joy'; import React, {useEffect} from 'react'; -import {debounce} from 'lodash'; import {getTypeMinField, renderAsinH, ZscaleCheckbox} from './ColorBandPanel.jsx'; import {ValidationField} from '../../ui/ValidationField.jsx'; import {RangeSlider} from '../../ui/RangeSlider.jsx'; import {FieldGroupCollapsible} from '../../ui/panel/CollapsiblePanel.jsx'; import {useWatcher} from 'firefly/ui/SimpleComponent.jsx'; -import ImagePlotCntlr from 'firefly/visualize/ImagePlotCntlr.js'; +import {ANY_REPLOT, CHANGE_ACTIVE_PLOT_VIEW} from '../VisConst'; import {dispatchForceFieldGroupReducer} from 'firefly/fieldGroup/FieldGroupCntlr.js'; const isDebug = () => window.firefly?.debugStretch ?? false; @@ -17,14 +16,14 @@ export const ColorRGBHuePreservingPanel= ({rgbFields,groupKey}) => { dispatchForceFieldGroupReducer(groupKey); },[]); - useWatcher([ImagePlotCntlr.ANY_REPLOT, ImagePlotCntlr.CHANGE_ACTIVE_PLOT_VIEW], + useWatcher([ANY_REPLOT, CHANGE_ACTIVE_PLOT_VIEW], (action) => { dispatchForceFieldGroupReducer(groupKey, action); } ); if (!rgbFields) return
; const {zscale} = rgbFields; - const zscaleValue = zscale?.value; + const zscaleValue = zscale?.value const renderRange = (isZscale) => { if (isZscale) { return null; diff --git a/src/firefly/js/visualize/ui/ColorTableDropDownView.jsx b/src/firefly/js/visualize/ui/ColorTableDropDownView.jsx index ec65cffbab..c3450517a8 100644 --- a/src/firefly/js/visualize/ui/ColorTableDropDownView.jsx +++ b/src/firefly/js/visualize/ui/ColorTableDropDownView.jsx @@ -2,7 +2,7 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import React, {useState, useEffect, useCallback, useRef} from 'react'; +import React, {useState, useEffect, useRef} from 'react'; import PropTypes from 'prop-types'; import {throttle, isArray, isNumber} from 'lodash'; import {hideColorPickerDialog, showColorPickerDialog} from '../../ui/ColorPicker'; @@ -10,12 +10,11 @@ import HelpIcon from '../../ui/HelpIcon.jsx'; import {ToolbarButton, ToolbarHorizontalSeparator} from '../../ui/ToolbarButton.jsx'; import {SingleColumnMenu} from '../../ui/DropDownMenu.jsx'; import {getBestContrast, toRGBAString} from '../../util/Color'; -import {dispatchColorChange, dispatchOverlayColorLocking} from '../ImagePlotCntlr.js'; +import {dispatchColorChange, dispatchOverlayColorLocking} from '../ImagePlotDispatch'; import { - primePlot, isThreeColor, getActivePlotView, isAllStretchDataLoaded, findPlotGroup, - hasOverlayColorLock, + primePlot, isThreeColor, isAllStretchDataLoaded, findPlotGroup, hasOverlayColorLock, currentP } from '../PlotViewUtil.js'; -import {visRoot} from '../ImagePlotCntlr.js'; +import {visRoot} from '../VisStoreRoots'; import { findAContrastColor, getColorModel, baseIdMatchesForOrRev, isReversedColor, makeColorTableImage, NO_COLOR_TABLE, reverseId, getCbarNumIds, getCbarTip @@ -28,7 +27,7 @@ import {RangeSliderView} from '../../ui/RangeSliderView.jsx'; import DialogRootContainer from 'firefly/ui/DialogRootContainer.jsx'; import {dispatchHideDialog, dispatchShowDialog} from 'firefly/core/ComponentCntlr.js'; import {DROP_DOWN_KEY} from 'firefly/ui/DropDownToolbarButton.jsx'; -import {Typography, Box, Stack, Divider, IconButton, Skeleton, Chip} from '@mui/joy'; +import {Typography, Box, Stack, Divider, IconButton, Skeleton} from '@mui/joy'; import LockIcon from '@mui/icons-material/Lock'; import LockOpenOutlinedIcon from '@mui/icons-material/LockOpenOutlined'; import ArrowOutwardOutlinedIcon from '@mui/icons-material/ArrowOutwardOutlined'; @@ -153,11 +152,10 @@ function getContrast(plot) { export function ColorStretchLockButton({allowPopout=false, sx={}}) { const overlayColorLocked= useStoreConnector( () => { - const vr= visRoot(); - const pv= getActivePlotView(vr); - return pv ? hasOverlayColorLock(pv,findPlotGroup(pv?.plotGroupId,vr.plotGroupAry)) : false; + const {pv}= currentP(); + return pv ? hasOverlayColorLock(pv,findPlotGroup(pv?.plotGroupId,visRoot().plotGroupAry)) : false; } ); - const pv= getActivePlotView(visRoot()); + const {pv}= currentP(); return ( { - const plot = useStoreConnector( () => primePlot(visRoot()) ); + const plot = useStoreConnector( () => currentP().plot ); const allLoaded = useStoreConnector(() => isAllStretchDataLoaded(visRoot())); const [bias,setBias]= useState( () => plot?.rawData.bandData[0].bias); const [contrast,setContrast]= useState( () => getContrast(plot)); @@ -541,7 +539,7 @@ export function showColorDialog() { function PopoutColorPanel() { - const pv = useStoreConnector( () => getActivePlotView(visRoot())); + const pv = useStoreConnector( () => currentP().pv); if (!primePlot(pv)) return
; return ( diff --git a/src/firefly/js/visualize/ui/CoveraeViewer.jsx b/src/firefly/js/visualize/ui/CoveraeViewer.jsx index a50b64faf4..15d4ac1efb 100644 --- a/src/firefly/js/visualize/ui/CoveraeViewer.jsx +++ b/src/firefly/js/visualize/ui/CoveraeViewer.jsx @@ -6,16 +6,12 @@ import React, {useEffect,useContext} from 'react'; import {get,once} from 'lodash'; import PropTypes from 'prop-types'; import {hasCoverageData} from '../../voAnalyzer/TableAnalysis.js'; -import {visRoot} from '../ImagePlotCntlr'; +import {DEFAULT_COVERAGE_VIEWER_ID, IMAGE, NewPlotMode, SINGLE} from '../VisConst'; import {MultiImageViewer} from './MultiImageViewer'; -import { - dispatchAddViewer, dispatchViewerUnmounted, getMultiViewRoot, getViewer, IMAGE, NewPlotMode, SINGLE, -} from '../MultiViewCntlr'; -import { - COVERAGE_WATCH_CID, startCoverageWatcher, COVERAGE_FAIL, COVERAGE_WAITING_MSG -} from '../saga/CoverageWatcher.js'; +import { dispatchAddViewer, dispatchViewerUnmounted, getMultiViewRoot, getViewer, } from '../MultiViewCntlr'; +import { COVERAGE_WATCH_CID, startCoverageWatcher, COVERAGE_FAIL, COVERAGE_WAITING_MSG} from '../saga/CoverageWatcher.js'; import {MultiViewStandardToolbar} from './MultiViewStandardToolbar'; -import {DEFAULT_COVERAGE_VIEWER_ID, getActivePlotView} from '../PlotViewUtil'; +import {currentP} from '../PlotViewUtil'; import {RenderTreeIdCtx} from '../../ui/RenderTreeIdCtx.jsx'; import {useStoreConnector} from '../../ui/SimpleComponent.jsx'; import {getActiveTableId, getBooleanMetaEntry, getTblById, getTblIdsByGroup} from '../../tables/TableUtil.js'; @@ -55,7 +51,7 @@ export function CoverageViewer({viewerId=DEFAULT_COVERAGE_VIEWER_ID,noCovMessage workingMessage='Working...'}) { startWatcher(viewerId); - const pv = useStoreConnector(() => getActivePlotView(visRoot())); // do not remove, forces a rerender + const pv = useStoreConnector(() => currentP().pv); // do not remove, forces a rerender const tbl_id = useStoreConnector(() => getActiveOrFirstTblId()); const isFetching= useStoreConnector(() => getTblById(getActiveOrFirstTblId())?.isFetching ?? false); const covState = useStoreConnector(() => getComponentState(COVERAGE_WATCH_CID,[])); diff --git a/src/firefly/js/visualize/ui/CtxToolbarFunctions.js b/src/firefly/js/visualize/ui/CtxToolbarFunctions.js index be720d3ded..ec0179c945 100644 --- a/src/firefly/js/visualize/ui/CtxToolbarFunctions.js +++ b/src/firefly/js/visualize/ui/CtxToolbarFunctions.js @@ -5,17 +5,14 @@ import {isNumber} from 'lodash'; -import HpxCatalog from '../../drawingLayers/hpx/HpxCatalog'; import { clearHpxFilterCatalog, filterHpxCatalog, selectHpxCatalog, unselectHxpCatalog } from '../../drawingLayers/hpx/HpxCatalogUtil'; +import {dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDestroyDrawLayer} from '../DrawLayerDispatch'; import { - getAllDrawLayersForPlot, - getDrawLayersByType, - getPlotViewById, - isDrawLayerAttached, - isMultiImageFitsWithSameArea, - primePlot + currentP, + getAllDrawLayersForPlot, getDrawLayersByType, getPlotViewById, isDrawLayerAttached, + isMultiImageFitsWithSameArea, primePlot, } from '../PlotViewUtil'; import {CysConverter} from '../CsysConverter'; import {PlotAttribute} from '../PlotAttribute'; @@ -28,12 +25,8 @@ import Catalog, { unselectCatalog } from '../../drawingLayers/Catalog'; import { - dispatchChangeCenterOfProjection, - dispatchCrop, - dispatchProcessScroll, - dispatchZoom, - visRoot -} from '../ImagePlotCntlr'; + dispatchChangeCenterOfProjection, dispatchCrop, dispatchProcessScroll, dispatchZoom +} from '../ImagePlotDispatch'; import LSSTFootprint, { clearFilterFootprint, filterFootprint, @@ -41,17 +34,17 @@ import LSSTFootprint, { unselectFootprint } from '../../drawingLayers/ImageLineBasedFootprint'; import {callGetAreaStatistics} from '../../rpc/PlotServicesJson'; +import {dlRoot} from '../VisStoreRoots'; import {showImageAreaStatsPopup} from './ImageStatsPopup'; import {logger} from '../../util/Logger.js'; import CoordUtil from '../CoordUtil'; import {isImageOverlayLayersActive} from '../RelatedDataUtil'; import {showInfoPopup} from '../../ui/PopupUtil'; -import {detachSelectArea, isOutlineImageForSelectArea, SELECT_AREA_TITLE} from './SelectAreaUIComponents'; +import {detachSelectArea} from './SelectAreaUIComponents'; import ImageOutline from '../../drawingLayers/ImageOutline'; import {convertAngle} from '../VisUtil'; import ShapeDataObj from '../draw/ShapeDataObj'; -import {dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDestroyDrawLayer, dlRoot} from '../DrawLayerCntlr'; -import {UserZoomTypes} from '../ZoomUtil'; +import {UserZoomTypes} from '../VisConst'; import {isHiPS, isImage} from '../WebPlot'; import {findScrollPtToCenterImagePt} from '../reducer/PlotView'; import {SelectedShape} from '../../drawingLayers/SelectedShape'; @@ -272,8 +265,7 @@ export function zoomIntoSelection(pv, try2=false) { if (isImage(p)) { - pv= getPlotViewById(visRoot(),plotId); - p= primePlot(pv); + const {pv,plot:p}= currentP(plotId); cc= CysConverter.make(p); const ip0= cc.getImageCoords(sel.pt0); const ip2= cc.getImageCoords(sel.pt1); @@ -286,7 +278,7 @@ export function zoomIntoSelection(pv, try2=false) { dispatchChangeCenterOfProjection({plotId,centerProjPt:userSearchWP}); } else { - p= primePlot(visRoot(),pv.plotId); + p= currentP(pv.plotId).plot; dispatchChangeCenterOfProjection({plotId,centerProjPt:sel.pt2}); cc= CysConverter.make(p); const dev0= cc.getDeviceCoords(sel.pt0); diff --git a/src/firefly/js/visualize/ui/DrawLayerPanel.jsx b/src/firefly/js/visualize/ui/DrawLayerPanel.jsx index 8466f0cb0f..5f5e6c9bd5 100644 --- a/src/firefly/js/visualize/ui/DrawLayerPanel.jsx +++ b/src/firefly/js/visualize/ui/DrawLayerPanel.jsx @@ -4,11 +4,11 @@ import React, {useLayoutEffect} from 'react'; import {dispatchShowDialog, dispatchHideDialog} from '../../core/ComponentCntlr.js'; -import {getActivePlotView, getAllDrawLayersForPlot, primePlot} from '../PlotViewUtil.js'; +import {getAllDrawLayersForPlot, currentP} from '../PlotViewUtil.js'; import DialogRootContainer from '../../ui/DialogRootContainer.jsx'; import {PopupPanel} from '../../ui/PopupPanel.jsx'; -import {getDlAry} from '../DrawLayerCntlr.js'; -import {visRoot} from '../ImagePlotCntlr.js'; + +import {getDlAry} from '../VisStoreRoots'; import {DrawLayerPanelView} from './DrawLayerPanelView.jsx'; import {flux} from '../../core/ReduxFlux.js'; import {lastMouseImageReadout} from '../VisMouseSync'; @@ -33,7 +33,7 @@ function getDialogBuilder() { } function makeState() { - const activePv= getActivePlotView(visRoot()); + const activePv= currentP().pv; const dlAry= getDlAry(); const imageOverlayLength= activePv ? activePv.overlayPlotViews.length : 0; const layersLength= activePv ? getAllDrawLayersForPlot(dlAry,activePv.plotId).length : 0; @@ -63,7 +63,7 @@ function DrawLayerPanel() { const defaultTitle = 'Layers- '; export function DrawLayerPanelTitle({}) { - const plotTitle = useStoreConnector(() => primePlot(visRoot())?.title ); + const plotTitle = useStoreConnector(() => currentP().plot?.title); return (plotTitle ? `${defaultTitle}${plotTitle}` : defaultTitle); } diff --git a/src/firefly/js/visualize/ui/DrawLayerPanelView.jsx b/src/firefly/js/visualize/ui/DrawLayerPanelView.jsx index 4a95ea2617..fd9c89f7b6 100644 --- a/src/firefly/js/visualize/ui/DrawLayerPanelView.jsx +++ b/src/firefly/js/visualize/ui/DrawLayerPanelView.jsx @@ -11,8 +11,10 @@ import React from 'react'; import ImageRoot from '../../drawingLayers/ImageRoot.js'; import {showColorPickerDialog} from '../../ui/ColorPicker.jsx'; import {showPointShapeSizePickerDialog} from '../../ui/PointShapeSizePicker.jsx'; -import {dispatchDetachLayerFromPlot} from '../DrawLayerCntlr.js'; -import {dispatchDeleteOverlayPlot, dispatchOverlayPlotChangeAttributes, visRoot} from '../ImagePlotCntlr.js'; + +import {dispatchDetachLayerFromPlot} from '../DrawLayerDispatch'; +import {dispatchDeleteOverlayPlot, dispatchOverlayPlotChangeAttributes} from '../ImagePlotDispatch'; +import {visRoot} from '../VisStoreRoots'; import {getAllDrawLayersForPlot, getHDU, getLayerTitle, isDrawLayerVisible, primePlot} from '../PlotViewUtil.js'; import { enableRelatedDataLayer, findUnactivatedRelatedData, operateOnOverlayPlotViewsThatMatch, setMaskVisible diff --git a/src/firefly/js/visualize/ui/DrawLayerUIComponents.jsx b/src/firefly/js/visualize/ui/DrawLayerUIComponents.jsx index e87f3dc454..4bffb56e69 100644 --- a/src/firefly/js/visualize/ui/DrawLayerUIComponents.jsx +++ b/src/firefly/js/visualize/ui/DrawLayerUIComponents.jsx @@ -11,10 +11,10 @@ import {ColorChangeType} from '../draw/DrawLayer'; import {DrawSymbol} from '../draw/DrawSymbol.js'; import DrawUtil from '../draw/DrawUtil'; import {SimpleCanvas} from '../draw/SimpleCanvas'; -import {dispatchChangeDrawingDef, dispatchChangeVisibility, getDlAry, GroupingScope} from '../DrawLayerCntlr'; -import {visRoot} from '../ImagePlotCntlr'; +import {dispatchChangeDrawingDef, dispatchChangeVisibility} from '../DrawLayerDispatch'; +import {getDlAry, visRoot} from '../VisStoreRoots'; +import {DEFAULT_COVERAGE_PLOT_ID, GroupingScope} from '../VisConst'; import { - DEFAULT_COVERAGE_PLOT_ID, getDrawLayerById, getDrawLayersByDisplayGroup, getLayerTitle, getPlotViewById, isDrawLayerVisible, primePlot } from '../PlotViewUtil'; diff --git a/src/firefly/js/visualize/ui/ExpandedOptionsPopup.jsx b/src/firefly/js/visualize/ui/ExpandedOptionsPopup.jsx index 03adee953a..409695e53d 100644 --- a/src/firefly/js/visualize/ui/ExpandedOptionsPopup.jsx +++ b/src/firefly/js/visualize/ui/ExpandedOptionsPopup.jsx @@ -20,7 +20,8 @@ import { isPlotFilterOrSortOutOfSync, makeImViewDisplayModel, removeImageViewDisplaySelected, syncSort, updateImageViewDisplay, addExpandFilterSyncWatcher } from '../ImViewFilterDisplay.js'; -import {dispatchAddViewer, dispatchAddViewerItems, EXPANDED_MODE_RESERVED, IMAGE} from '../MultiViewCntlr.js'; +import {dispatchAddViewer, dispatchAddViewerItems} from '../MultiViewCntlr.js'; +import {EXPANDED_MODE_RESERVED, IMAGE} from '../VisConst'; import {deleteAllFailedPlots, isPlotViewArysEqual} from '../PlotViewUtil.js'; import {ListViewButton} from './Buttons.jsx'; diff --git a/src/firefly/js/visualize/ui/ExtractionWatchers.js b/src/firefly/js/visualize/ui/ExtractionWatchers.js index 9b05b9c8c9..b9f3159d95 100644 --- a/src/firefly/js/visualize/ui/ExtractionWatchers.js +++ b/src/firefly/js/visualize/ui/ExtractionWatchers.js @@ -3,13 +3,13 @@ */ import {isEmpty} from 'lodash'; import {dispatchAddActionWatcher} from 'firefly/core/MasterSaga.js'; -import ImagePlotCntlr, {dispatchChangePrimePlot} from 'firefly/visualize/ImagePlotCntlr.js'; import { - dispatchTableHighlight, - TABLE_HIGHLIGHT, - TABLE_LOADED, - TABLE_REMOVE, - TABLE_SELECT, + dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDestroyDrawLayer, dispatchModifyCustomField +} from '../DrawLayerDispatch'; +import {dispatchChangePrimePlot} from '../ImagePlotDispatch'; +import {CHANGE_PRIME_PLOT} from '../VisConst'; +import { + dispatchTableHighlight, TABLE_HIGHLIGHT, TABLE_LOADED, TABLE_REMOVE, TABLE_SELECT, TABLE_UPDATE, TBL_RESULTS_ACTIVE } from 'firefly/tables/TablesCntlr.js'; import {getCellValue, getColumnIdx, getMetaEntry, getTblById} from 'firefly/tables/TableUtil.js'; @@ -18,13 +18,9 @@ import { convertHDUIdxToImageIdx, getDrawLayerById, getHDU, getHDUIndex, getImageCubeIdx, isImageCube, primePlot } from 'firefly/visualize/PlotViewUtil.js'; import {makeImagePt, parseImagePt} from 'firefly/visualize/Point.js'; -import { - dispatchAttachLayerToPlot, - dispatchCreateDrawLayer, - dispatchDestroyDrawLayer, dispatchModifyCustomField, dlRoot -} from 'firefly/visualize/DrawLayerCntlr.js'; import SearchTarget from 'firefly/drawingLayers/SearchTarget.js'; import {findPlotViewUsingFitsPathMeta} from 'firefly/visualize/saga/CatalogWatcher.js'; +import {dlRoot} from '../VisStoreRoots'; let idCnt=0; @@ -40,7 +36,7 @@ export function addZAxisExtractionWatcher(tbl_id) { id: 'plot-zaxis-watcher-${idCnt}--'+tbl_id, callback:zAxisExtractionPlotWatcher, params:{tbl_id}, - actions:[ImagePlotCntlr.CHANGE_PRIME_PLOT, TABLE_REMOVE] + actions:[CHANGE_PRIME_PLOT, TABLE_REMOVE] }); } diff --git a/src/firefly/js/visualize/ui/FileUploadViewPanel.jsx b/src/firefly/js/visualize/ui/FileUploadViewPanel.jsx index e5d306b867..30fae695fe 100644 --- a/src/firefly/js/visualize/ui/FileUploadViewPanel.jsx +++ b/src/firefly/js/visualize/ui/FileUploadViewPanel.jsx @@ -42,7 +42,7 @@ import {getSizeAsString} from '../../util/WebUtil.js'; import {isAnalysisTableDatalink} from '../../voAnalyzer/VoDataLinkServDef.js'; import {isMOCFitsFromUploadAnalsysis} from '../HiPSMocUtil.js'; -import ImagePlotCntlr from '../ImagePlotCntlr.js'; +import {PLOT_PROGRESS_UPDATE} from '../VisConst'; import {isLsstFootprintTable} from '../task/LSSTFootprintTask.js'; import {getWorkspaceConfig, isAccessWorkspace} from '../WorkspaceCntlr.js'; @@ -149,7 +149,7 @@ export function FileUploadViewPanel({setSubmitText, acceptList, acceptOneItem, e const watchForUploadUpdate= ({payload}) => { payload.requestKey===statusKey && setLoadingMsg(payload.message); }; - dispatchAddActionWatcher({ id: statusKey, actions:[ImagePlotCntlr.PLOT_PROGRESS_UPDATE], + dispatchAddActionWatcher({ id: statusKey, actions:[PLOT_PROGRESS_UPDATE], callback:watchForUploadUpdate, params:{statusKey}}); } } diff --git a/src/firefly/js/visualize/ui/FitsHeaderView.jsx b/src/firefly/js/visualize/ui/FitsHeaderView.jsx index b13c8901a6..b2e8f32fa2 100644 --- a/src/firefly/js/visualize/ui/FitsHeaderView.jsx +++ b/src/firefly/js/visualize/ui/FitsHeaderView.jsx @@ -6,7 +6,7 @@ import {Stack, Typography} from '@mui/joy'; import React from 'react'; import DialogRootContainer from '../../ui/DialogRootContainer.jsx'; import {LayoutType, PopupPanel} from '../../ui/PopupPanel.jsx'; -import {primePlot, getPlotViewById, isImageCube, getCubePlaneCnt} from '../PlotViewUtil.js'; +import {primePlot, isImageCube, getCubePlaneCnt, currentP} from '../PlotViewUtil.js'; import {Tabs, Tab} from '../../ui/panel/TabPanel.jsx'; import {TablePanel} from '../../tables/ui/TablePanel.jsx'; import {dispatchShowDialog, dispatchHideDialog, isDialogVisible} from '../../core/ComponentCntlr.js'; @@ -17,11 +17,11 @@ import HelpIcon from '../../ui/HelpIcon.jsx'; import {getPixScaleArcSec} from '../WebPlot.js'; import {Band} from '../Band.js'; import {dispatchAddActionWatcher} from '../../core/MasterSaga.js'; -import ImagePlotCntlr, {visRoot} from '../ImagePlotCntlr.js'; +import {CHANGE_ACTIVE_PLOT_VIEW, CHANGE_PRIME_PLOT, DELETE_PLOT_VIEW, PLOT_IMAGE} from '../VisConst'; import {getTblById} from '../../tables/TableUtil.js'; import {TABLE_SORT, TABLE_REPLACE, dispatchTableSort} from '../../tables/TablesCntlr.js'; import {getHDU, isThreeColor} from '../PlotViewUtil'; -import { getAllValuesOfHeader, } from '../FitsHeaderUtil.js'; +import {getAllValuesOfHeader} from '../FitsHeaderUtil.js'; const popupPanelResizableSx = { width: 550, minWidth: 448, height: 400, minHeight: 300, resize: 'both', overflow: 'hidden', position: 'relative'}; @@ -55,7 +55,7 @@ function popupForm(plot, fitsHeaderInfo, popupId) { function showFitsHeaderPopup(plot, fitsHeaderInfo, element, initLeft, initTop, onMove) { const getTitle = (p) => { - const pv = getPlotViewById(visRoot(), p.plotId); + const {pv} = currentP(p.plotId); let title; if (pv.plots.length === 1) { title = p.title; @@ -89,7 +89,7 @@ function showFitsHeaderPopup(plot, fitsHeaderInfo, element, initLeft, initTop, o if (!isDialogVisible(FITS_HEADER_POPUP_ID)) { cancelSelf(); } else { - const crtPlot = primePlot(visRoot()); + const crtPlot = currentP().plot; const newTableInfo = createFitsHeaderTable(null, crtPlot); if (!newTableInfo) return {displayedPlotId, displayedHdu}; @@ -98,7 +98,7 @@ function showFitsHeaderPopup(plot, fitsHeaderInfo, element, initLeft, initTop, o return prev; }, false); - if (action.type===ImagePlotCntlr.PLOT_IMAGE || isThreeColor(plot) || displayedPlotId!==crtPlot.plotId || displayedHdu!==getHDU(crtPlot) ) { + if (action.type===PLOT_IMAGE || isThreeColor(plot) || displayedPlotId!==crtPlot.plotId || displayedHdu!==getHDU(crtPlot) ) { updatePopup(crtPlot, newTableInfo); } displayedPlotId= crtPlot.plotId; @@ -135,10 +135,7 @@ function showFitsHeaderPopup(plot, fitsHeaderInfo, element, initLeft, initTop, o if (!isDialogVisible(FITS_HEADER_POPUP_ID)) { - dispatchAddActionWatcher({actions: [ImagePlotCntlr.CHANGE_ACTIVE_PLOT_VIEW, - ImagePlotCntlr.CHANGE_PRIME_PLOT, - ImagePlotCntlr.PLOT_IMAGE, - ImagePlotCntlr.DELETE_PLOT_VIEW], + dispatchAddActionWatcher({actions: [CHANGE_ACTIVE_PLOT_VIEW, CHANGE_PRIME_PLOT, PLOT_IMAGE, DELETE_PLOT_VIEW], callback: watchActivePlotChange, id: 'fits-header-view-watch-active-plot-change' }); @@ -243,7 +240,7 @@ function renderFileSizeAndPixelSize(plot, band, fitsHeaderInfo, isOnTab) { ); } else { - return overview + return overview; } } diff --git a/src/firefly/js/visualize/ui/GroupedImageViewerContainer.jsx b/src/firefly/js/visualize/ui/GroupedImageViewerContainer.jsx index dddc4bbc85..21b68187b9 100644 --- a/src/firefly/js/visualize/ui/GroupedImageViewerContainer.jsx +++ b/src/firefly/js/visualize/ui/GroupedImageViewerContainer.jsx @@ -6,11 +6,10 @@ import React, {PureComponent} from 'react'; import PropTypes from 'prop-types'; import {MultiViewStandardToolbar} from './MultiViewStandardToolbar.jsx'; import {MultiImageViewer} from './MultiImageViewer.jsx'; -import {DEFAULT_FITS_VIEWER_ID, NewPlotMode} from '../MultiViewCntlr.js'; +import {DEFAULT_FITS_VIEWER_ID, ExpandType, NewPlotMode} from '../VisConst'; import {LO_MODE, LO_VIEW, dispatchSetLayoutMode} from '../../core/LayoutCntlr.js'; -import {dispatchChangeExpandedMode, ExpandType} from '../ImagePlotCntlr.js'; -import {visRoot} from '../ImagePlotCntlr.js'; -import {getPlotViewById} from './../PlotViewUtil.js'; +import {dispatchChangeExpandedMode} from '../ImagePlotDispatch'; +import {currentP} from '../PlotViewUtil'; /** * A wrapper component for a group grid view that supported expanded mode @@ -25,8 +24,7 @@ export class GroupedImageViewerContainer extends PureComponent { layoutGrid(plotIdAry) { const {gridDefs, size= 200}= this.props; - const vr= visRoot(); - const pvAry= plotIdAry.map( (plotId) => getPlotViewById(vr, plotId)); + const pvAry= plotIdAry.map( (plotId) => currentP(plotId).pv); return gridDefs .map( (r) => { diff --git a/src/firefly/js/visualize/ui/HiPSSearchPanel.jsx b/src/firefly/js/visualize/ui/HiPSSearchPanel.jsx index aa9b6c3ba5..5b39af3899 100644 --- a/src/firefly/js/visualize/ui/HiPSSearchPanel.jsx +++ b/src/firefly/js/visualize/ui/HiPSSearchPanel.jsx @@ -3,8 +3,8 @@ import {object, shape} from 'prop-types'; import React, {useRef} from 'react'; import {FormPanel} from '../../ui/FormPanel.jsx'; import {validateUrl} from '../../util/Validate.js'; -import {dispatchPlotHiPS} from '../ImagePlotCntlr.js'; -import {DEFAULT_FITS_VIEWER_ID} from '../MultiViewCntlr.js'; +import {dispatchPlotHiPS} from '../ImagePlotDispatch'; +import {DEFAULT_FITS_VIEWER_ID} from '../VisConst'; import {showInfoPopup} from '../../ui/PopupUtil.jsx'; import {FieldGroup} from '../../ui/FieldGroup.jsx'; import {getNextHiPSPlotId} from '../PlotViewUtil.js'; diff --git a/src/firefly/js/visualize/ui/ImageCenterDropDown.jsx b/src/firefly/js/visualize/ui/ImageCenterDropDown.jsx index 855216b106..2e61d540e7 100644 --- a/src/firefly/js/visualize/ui/ImageCenterDropDown.jsx +++ b/src/firefly/js/visualize/ui/ImageCenterDropDown.jsx @@ -1,13 +1,15 @@ import {Stack} from '@mui/joy'; import React, {useState} from 'react'; import {get} from 'lodash'; -import {primePlot} from '../PlotViewUtil.js'; +import {dispatchAttachLayerToPlot, dispatchCreateDrawLayer} from '../DrawLayerDispatch'; +import {currentP} from '../PlotViewUtil.js'; +import {getDlAry} from '../VisStoreRoots'; import {isImage} from '../WebPlot.js'; import {PlotAttribute} from '../PlotAttribute'; import {SingleColumnMenu} from '../../ui/DropDownMenu.jsx'; import {DropDownVerticalSeparator, ToolbarButton} from '../../ui/ToolbarButton.jsx'; -import {getActivePlotView, getDrawLayersByType} from '../PlotViewUtil'; -import {dispatchChangeTableAutoScroll, dispatchRecenter} from '../ImagePlotCntlr'; +import {getDrawLayersByType} from '../PlotViewUtil'; +import {dispatchChangeTableAutoScroll, dispatchRecenter} from '../ImagePlotDispatch'; import {getTableGroup} from '../../tables/TableUtil'; import {TargetPanel} from '../../ui/TargetPanel.jsx'; import {FieldGroup} from '../../ui/FieldGroup.jsx'; @@ -16,7 +18,6 @@ import {parseWorldPt, pointEquals} from '../Point'; import {dispatchAddPreference, getPreference} from '../../core/AppDataCntlr'; import {DropDownSubMenu} from '../../ui/DropDownMenu'; import FixedMarker from '../../drawingLayers/FixedMarker'; -import {dispatchAttachLayerToPlot, dispatchCreateDrawLayer, getDlAry} from '../DrawLayerCntlr'; import {CenterDropdown} from './Buttons.jsx'; import {formatWorldPt, formatWorldPtToString, formatWorldPtToStringSimple} from './WorldPtFormat'; @@ -56,8 +57,7 @@ function hasTablesWithCoordinates(pv) { export function ImageCenterDropDown({visRoot:vr, visible, mi}) { - const pv= getActivePlotView(vr); - const plot= primePlot(pv); + const {pv,plot}= currentP(); const coordTables= hasTablesWithCoordinates(pv); const hasSearchTarget= Boolean( (get(plot, ['attributes',PlotAttribute.FIXED_TARGET]) && pv.plotViewCtx.displayFixedTarget) || @@ -79,7 +79,7 @@ export function ImageCenterDropDown({visRoot:vr, visible, mi}) { const createMarkerAndMoveToTarget= (fields) => { const wp= parseWorldPt(get(fields,'UserTargetWorldPt')); if (!wp) return; - const pv= getActivePlotView(vr); + const {pv}= currentP(); if (!pv) return; moveToTarget(fields); diff --git a/src/firefly/js/visualize/ui/ImageMetaDataToolbar.jsx b/src/firefly/js/visualize/ui/ImageMetaDataToolbar.jsx index 066428f5f8..24dcf3d5b6 100644 --- a/src/firefly/js/visualize/ui/ImageMetaDataToolbar.jsx +++ b/src/firefly/js/visualize/ui/ImageMetaDataToolbar.jsx @@ -7,10 +7,10 @@ import PropTypes, {element} from 'prop-types'; import {omit} from 'lodash'; import {flux} from '../../core/ReduxFlux.js'; import shallowequal from 'shallowequal'; +import {SINGLE} from '../VisConst'; import {ImageMetaDataToolbarView} from './ImageMetaDataToolbarView.jsx'; import {makeDataProductsConverter} from '../../metaConvert/DataProductsFactory.js'; import {getTblById} from '../../tables/TableUtil.js'; -import {SINGLE} from '../MultiViewCntlr.js'; export class ImageMetaDataToolbar extends Component { diff --git a/src/firefly/js/visualize/ui/ImageMetaDataToolbarView.jsx b/src/firefly/js/visualize/ui/ImageMetaDataToolbarView.jsx index 43790af55b..ee4bd16145 100644 --- a/src/firefly/js/visualize/ui/ImageMetaDataToolbarView.jsx +++ b/src/firefly/js/visualize/ui/ImageMetaDataToolbarView.jsx @@ -13,8 +13,9 @@ import {ToolbarHorizontalSeparator} from '../../ui/ToolbarButton.jsx'; import {showInfoPopup} from '../../ui/PopupUtil.jsx'; import { dispatchChangeViewerLayout, getViewer, getMultiViewRoot, - GRID_FULL, GRID_RELATED, SINGLE, GRID, getLayoutDetails + getLayoutDetails } from '../MultiViewCntlr.js'; +import {GRID, GRID_FULL, GRID_RELATED, SINGLE} from '../VisConst'; import {DisplayTypeButtonGroup, ThreeColor} from './Buttons.jsx'; import {showColorBandChooserPopup} from './ColorBandChooserPopup.jsx'; import {ImagePager} from './ImagePager.jsx'; diff --git a/src/firefly/js/visualize/ui/ImageSearchPanelV2.jsx b/src/firefly/js/visualize/ui/ImageSearchPanelV2.jsx index a082f27167..9ef25ed498 100644 --- a/src/firefly/js/visualize/ui/ImageSearchPanelV2.jsx +++ b/src/firefly/js/visualize/ui/ImageSearchPanelV2.jsx @@ -33,14 +33,13 @@ import {isDefined} from '../../util/WebUtil'; import WebPlotRequest, {WPConst} from '../../visualize/WebPlotRequest.js'; import CoordinateSys from '../CoordSys'; import {useForImageSearch} from '../HiPSListUtil.js'; -import {dispatchPlotHiPS, dispatchPlotImage, visRoot} from '../ImagePlotCntlr.js'; -import { - DEFAULT_FITS_VIEWER_ID, findViewerWithItemId, getAViewFromMultiView, getMultiViewRoot, getViewer, IMAGE, NewPlotMode -} from '../MultiViewCntlr.js'; +import {dispatchPlotHiPS, dispatchPlotImage} from '../ImagePlotDispatch'; +import {findViewerWithItemId, getAViewFromMultiView, getMultiViewRoot, getViewer} from '../MultiViewCntlr.js'; import {PlotAttribute} from '../PlotAttribute'; import { - DEFAULT_COVERAGE_PLOT_ID, DEFAULT_COVERAGE_VIEWER_ID, getNextHiPSPlotId, getPlotViewById -} from '../PlotViewUtil.js'; + DEFAULT_COVERAGE_PLOT_ID, DEFAULT_COVERAGE_VIEWER_ID, DEFAULT_FITS_VIEWER_ID, IMAGE, NewPlotMode +} from '../VisConst'; +import {currentP, getNextHiPSPlotId} from '../PlotViewUtil.js'; import {parseWorldPt} from '../Point.js'; import {convertCelestial} from '../VisUtil'; import {getWorkspaceConfig} from '../WorkspaceCntlr.js'; @@ -68,7 +67,7 @@ const scrollDivId = 'ImageSearchScroll'; */ function getContexInfo(renderTreeId, presetViewerId) { const mvroot = getMultiViewRoot(); - let plotId = visRoot()?.activePlotId; + let plotId = currentP().plotId; let viewerId= presetViewerId ? presetViewerId : (plotId && findViewerWithItemId(mvroot, plotId, IMAGE)); let viewer = getViewer(mvroot, viewerId); @@ -629,7 +628,7 @@ function doImageSearch({ imageMasterData, request, plotId, plotGroupId, viewerId const pvOptions= {}; if (plotId) { viewerId = findViewerWithItemId(getMultiViewRoot(), plotId, IMAGE); - const pv = getPlotViewById(visRoot(), plotId); + const {pv} = currentP(plotId); if (pv) { plotGroupId = pv.plotGroupId; pvOptions.displayFixedTarget= pv.plotViewCtx.displayFixedTarget; @@ -641,7 +640,7 @@ function doImageSearch({ imageMasterData, request, plotId, plotGroupId, viewerId //If the group id exists, add the image into the same group const viewer = getViewer(getMultiViewRoot(), viewerId); if (viewer && viewer.itemIdAry[0]) { - const pv = getPlotViewById(visRoot(), viewer.itemIdAry[0]); + const {pv} = currentP(viewer.itemIdAry[0]); if (pv) { plotGroupId = pv.plotGroupId; } diff --git a/src/firefly/js/visualize/ui/ImageStatsPopup.jsx b/src/firefly/js/visualize/ui/ImageStatsPopup.jsx index 85f0cbfbe4..485ae16215 100644 --- a/src/firefly/js/visualize/ui/ImageStatsPopup.jsx +++ b/src/firefly/js/visualize/ui/ImageStatsPopup.jsx @@ -7,12 +7,10 @@ import React, {useState} from 'react'; import PropTypes from 'prop-types'; import CompleteButton from '../../ui/CompleteButton.jsx'; import DialogRootContainer from '../../ui/DialogRootContainer.jsx'; -import {getDlAry} from '../DrawLayerCntlr.js'; -import {dispatchCreateDrawLayer, - dispatchAttachLayerToPlot, - dispatchDetachLayerFromPlot, - dispatchModifyCustomField, - dispatchDestroyDrawLayer} from '../DrawLayerCntlr.js'; +import { + dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDestroyDrawLayer, dispatchDetachLayerFromPlot, + dispatchModifyCustomField +} from '../DrawLayerDispatch'; import {getDrawLayerByType, isDrawLayerAttached } from '../PlotViewUtil.js'; import {Tabs, Tab} from '../../ui/panel/TabPanel.jsx'; @@ -21,6 +19,7 @@ import HelpIcon from '../../ui/HelpIcon.jsx'; import StatsPoint from '../../drawingLayers/StatsPoint.js'; import {PopupPanel} from '../../ui/PopupPanel.jsx'; import {dispatchShowDialog} from '../../core/ComponentCntlr.js'; +import {getDlAry} from '../VisStoreRoots'; const popupId = 'ImageAreaStatsPopup'; diff --git a/src/firefly/js/visualize/ui/ImageTableRowViewer.jsx b/src/firefly/js/visualize/ui/ImageTableRowViewer.jsx index e419383357..2eb706fd63 100644 --- a/src/firefly/js/visualize/ui/ImageTableRowViewer.jsx +++ b/src/firefly/js/visualize/ui/ImageTableRowViewer.jsx @@ -20,19 +20,20 @@ import {callWhileAwaiting} from '../../util/WebUtil'; import {ImageViewerPlaceHolder} from '../iv/ImageViewer'; import {onPlotComplete} from '../PlotCompleteMonitor'; import {RotateType} from '../PlotState'; -import {UserZoomTypes} from '../ZoomUtil'; +import {visRoot} from '../VisStoreRoots'; import {MultiImageViewer} from './MultiImageViewer.jsx'; -import {dispatchReplaceViewerItems, getMultiViewRoot, getViewer, IMAGE, NewPlotMode,} from '../MultiViewCntlr.js'; +import {dispatchReplaceViewerItems, getMultiViewRoot, getViewer} from '../MultiViewCntlr.js'; import { - dispatchChangeActivePlotView, dispatchDeletePlotView, - dispatchPlotImage, dispatchRecenter, dispatchRotate, dispatchWcsMatch, dispatchZoom, visRoot, WcsMatchType -} from '../ImagePlotCntlr.js'; + dispatchChangeActivePlotView, dispatchDeletePlotView, dispatchPlotImage, dispatchRecenter, dispatchRotate, + dispatchWcsMatch, dispatchZoom +} from '../ImagePlotDispatch'; import {SORT_ASC, SortInfo, UNSORTED} from '../../tables/SortInfo.js'; +import {IMAGE, NewPlotMode, UserZoomTypes, WcsMatchType} from '../VisConst'; import {CloseButton} from 'firefly/ui/CloseButton'; import {VisMiniToolbar} from './VisMiniToolbar.jsx'; import {FieldGroup} from '../../ui/FieldGroup.jsx'; import {RadioGroupInputField} from '../../ui/RadioGroupInputField.jsx'; -import {getActivePlotView, getPlotViewAry, getPlotViewById} from '../PlotViewUtil.js'; +import {currentP, getPlotViewAry, getPlotViewById} from '../PlotViewUtil.js'; import {isImageDataRequestedEqual} from '../WebPlotRequest.js'; import {dispatchTableHighlight} from 'firefly/tables/TablesCntlr'; import {Box, Stack, Typography} from '@mui/joy'; @@ -261,7 +262,7 @@ function Toolbar({viewerId, tableId:tbl_id, closeFunc=null, maxImageCnt, default useEffect(()=>{ if (matchInit.wcsMatchInitDone) return; - const pv= getPlotViewById(visRoot(),activePlotId); + const {pv}= currentP() const plotId= (!pv || pv.plotViewCtx.useForCoverage || !pv.plotViewCtx.useForSearchResults) ? undefined : activePlotId; if(plotId && wcsMatchType!==defaultWcsMatchType) { //to make sure wcsMatch checkbox is checked on initial render @@ -378,7 +379,7 @@ const changeHighlightedRow = (table, rowToHighlight, hRowChangedByUI) => { const changeActivePlot = (viewerId, table, plotIdxToActivate) => { const newActivePlotId = makePlotId(viewerId, plotIdxToActivate); - if (getActivePlotView(visRoot())?.plotId !== newActivePlotId) { + if (currentP().plotId !== newActivePlotId) { dispatchChangeActivePlotView(newActivePlotId); // if (plotIdxToActivate >= 0 && plotIdxToActivate < table?.totalRows) activePlotChangedByUI.current = false; } @@ -461,7 +462,7 @@ async function doLayoutImages({viewerId, imageCnt, table, makeRequestFromRow, .filter(({plotId}) => plotId.startsWith(root)) .filter(({plotId}) => plotId !== mpwWcsPrimId) .filter(({plotId}) => !keepPlotIdAry.includes(plotId)) - .forEach(({plotId}) => dispatchDeletePlotView({plotId, holdWcsMatch: true})); + .forEach(({plotId}) => dispatchDeletePlotView({plotId})); } } diff --git a/src/firefly/js/visualize/ui/MarkerDropDownView.jsx b/src/firefly/js/visualize/ui/MarkerDropDownView.jsx index 17843225fe..d1b496700d 100644 --- a/src/firefly/js/visualize/ui/MarkerDropDownView.jsx +++ b/src/firefly/js/visualize/ui/MarkerDropDownView.jsx @@ -7,12 +7,12 @@ import PropTypes from 'prop-types'; import {SingleColumnMenu, DropDownSubMenu} from '../../ui/DropDownMenu.jsx'; import {ToolbarButton, DropDownVerticalSeparator} from '../../ui/ToolbarButton.jsx'; -import { dispatchCreateMarkerLayer, dispatchCreateFootprintLayer } from '../DrawLayerCntlr.js'; -import {visRoot} from '../ImagePlotCntlr.js'; +import {dispatchCreateFootprintLayer, dispatchCreateMarkerLayer} from '../DrawLayerDispatch'; +import {currentP} from '../PlotViewUtil'; import {FootprintFactory, FootprintList, SOFIA_INSTRUMENTS} from '../draw/FootprintFactory.js'; import { createNewFootprintLayerId, getFootprintLayerTitle} from '../../drawingLayers/FootprintTool.js'; import {relocatable} from '../../drawingLayers/FootprintLocatable.js'; -import {has, get} from 'lodash'; +import {has} from 'lodash'; let idCntM = 0; let idCntF = 0; @@ -27,7 +27,7 @@ function displayItemText(itemName) { } } -const getPlotId = (pv) => ( pv ? pv.plotId : get(visRoot(), 'activePlotId')); +const getPlotId = (pv) => ( pv ? pv.plotId : currentP().plotId); export function addNewDrawLayer(pv, itemName) { if (!has(markerItem, itemName)) return; diff --git a/src/firefly/js/visualize/ui/MaskAddPanel.jsx b/src/firefly/js/visualize/ui/MaskAddPanel.jsx index 5be532e509..93dac97ccf 100644 --- a/src/firefly/js/visualize/ui/MaskAddPanel.jsx +++ b/src/firefly/js/visualize/ui/MaskAddPanel.jsx @@ -10,17 +10,17 @@ import {PopupPanel} from '../../ui/PopupPanel.jsx'; import {FileUpload} from '../../ui/FileUpload.jsx'; import CompleteButton from '../../ui/CompleteButton.jsx'; import Validate from '../../util/Validate.js'; -import {dispatchPlotMask, visRoot} from '../ImagePlotCntlr.js'; +import {dispatchPlotMask} from '../ImagePlotDispatch'; import DialogRootContainer from '../../ui/DialogRootContainer.jsx'; import {dispatchShowDialog} from '../../core/ComponentCntlr.js'; -import {getActivePlotView} from '../PlotViewUtil.js'; +import {currentP} from '../PlotViewUtil.js'; export function showMaskDialog() { const content= ( - + ); DialogRootContainer.defineDialog('MaskChooseDialog', content); @@ -29,7 +29,7 @@ export function showMaskDialog() { -export function MaskAddPanel({vr}) { +export function MaskAddPanel({}) { return ( @@ -64,7 +64,7 @@ export function MaskAddPanel({vr}) { }} /> resultsSuccess(r,visRoot())} + onSuccess={(r) => resultsSuccess(r)} dialogId='MaskChooseDialog' /> @@ -79,9 +79,9 @@ export function MaskAddPanel({vr}) { const maskIdRoot= 'USER_LOADED_MASK_'; var maskCnt= 0; -function resultsSuccess(request,vr) { +function resultsSuccess(request) { - const pv= getActivePlotView(vr); + const {pv}= currentP(); const maskV= Number(request.maskIdx); const hdu= Number(request.hduIdx); const fileKey= request.maskFile; diff --git a/src/firefly/js/visualize/ui/MatchLockDropDown.jsx b/src/firefly/js/visualize/ui/MatchLockDropDown.jsx index d8f60d9e1d..4186389ff0 100644 --- a/src/firefly/js/visualize/ui/MatchLockDropDown.jsx +++ b/src/firefly/js/visualize/ui/MatchLockDropDown.jsx @@ -1,7 +1,8 @@ import {Box, Tooltip, Typography} from '@mui/joy'; import React from 'react'; import {get} from 'lodash'; -import {dispatchWcsMatch, WcsMatchType} from '../ImagePlotCntlr.js'; +import {dispatchWcsMatch} from '../ImagePlotDispatch'; +import {WcsMatchType} from '../VisConst'; import {getPlotViewAry, hasWCSProjection, primePlot} from '../PlotViewUtil.js'; import {PlotAttribute} from '../PlotAttribute'; import {SingleColumnMenu} from '../../ui/DropDownMenu.jsx'; diff --git a/src/firefly/js/visualize/ui/MouseReadPopoutAll.jsx b/src/firefly/js/visualize/ui/MouseReadPopoutAll.jsx index 8a62a50476..4b82eed409 100644 --- a/src/firefly/js/visualize/ui/MouseReadPopoutAll.jsx +++ b/src/firefly/js/visualize/ui/MouseReadPopoutAll.jsx @@ -8,11 +8,11 @@ import { HIPS_STANDARD_READOUT, isLockByClick, readoutRoot, STANDARD_READOUT } from 'firefly/visualize/MouseReadoutCntlr.js'; import {useMouseStoreConnector} from 'firefly/visualize/ui/MouseStoreConnector.jsx'; -import {visRoot} from 'firefly/visualize/ImagePlotCntlr.js'; +import {visRoot} from '../VisStoreRoots'; import {getAppOptions} from 'firefly/core/AppDataCntlr.js'; import {ThumbnailView} from 'firefly/visualize/ui/ThumbnailView.jsx'; import {MagnifiedView} from 'firefly/visualize/ui/MagnifiedView.jsx'; -import {getActivePlotView, getPlotViewById, primePlot} from 'firefly/visualize/PlotViewUtil.js'; +import {currentP, getPlotViewById, primePlot} from 'firefly/visualize/PlotViewUtil.js'; import {getFluxInfo, getFluxRadix, getNonFluxDisplayElements} from 'firefly/visualize/ui/MouseReadoutUIUtil.js'; import {DataReadoutItem, MouseReadoutLock} from 'firefly/visualize/ui/MouseReadout.jsx'; import {isImage} from 'firefly/visualize/WebPlot.js'; @@ -36,7 +36,7 @@ function MousePopup({closeCallback,visible, requestOnTop, dialogId, zIndex, requ const {vr,currMouseState, readout, readoutData}= useMouseStoreConnector(makeState); return (
- @@ -47,7 +47,7 @@ function MousePopup({closeCallback,visible, requestOnTop, dialogId, zIndex, requ function PopoutMouseReadoutContents({vr,currMouseState, readout, readoutData}) { const showHealpixPixel= getAppOptions()?.hips?.readoutShowsPixel ?? false; - const pv= getActivePlotView(vr); + const {pv}= currentP(); const mousePv= getPlotViewById(vr,currMouseState.plotId); const pvForThumbnail= currMouseState.mouseState===MouseState.EXIT ? pv : mousePv; @@ -81,7 +81,7 @@ function Readout({readout, readoutData, showHealpixPixel=false, radix}){ const isHiPS= readoutType===HIPS_STANDARD_READOUT; const image= readoutType===STANDARD_READOUT; - const {plotState}= primePlot(visRoot(),plotId) ?? {}; + const {plotState}= currentP(plotId).plot ?? {}; const redUsed= threeColor && image && plotState.isBandUsed(Band.RED); const greenUsed= threeColor && image && plotState.isBandUsed(Band.GREEN); const blueUsed= threeColor && image && plotState.isBandUsed(Band.BLUE); diff --git a/src/firefly/js/visualize/ui/MouseReadout.jsx b/src/firefly/js/visualize/ui/MouseReadout.jsx index cb0fd13255..84d0a4f67e 100644 --- a/src/firefly/js/visualize/ui/MouseReadout.jsx +++ b/src/firefly/js/visualize/ui/MouseReadout.jsx @@ -6,7 +6,7 @@ import {Box, Chip, Stack, Switch, Typography} from '@mui/joy'; import React, {Fragment,memo, useState} from 'react'; import {number,string,oneOfType,object,func,bool} from 'prop-types'; import {EMPTY_BUNIT_DEFAULT} from '../FitsHeaderUtil'; -import {dispatchChangePointSelection} from '../ImagePlotCntlr.js'; +import {dispatchChangePointSelection} from '../ImagePlotDispatch'; import {dispatchChangeLockByClick} from '../MouseReadoutCntlr.js'; import {copyToClipboard} from '../../util/WebUtil'; import {ToolbarButton} from '../../ui/ToolbarButton'; diff --git a/src/firefly/js/visualize/ui/MouseReadoutBottomLine.jsx b/src/firefly/js/visualize/ui/MouseReadoutBottomLine.jsx index 8aa05c11cb..3c89436c13 100644 --- a/src/firefly/js/visualize/ui/MouseReadoutBottomLine.jsx +++ b/src/firefly/js/visualize/ui/MouseReadoutBottomLine.jsx @@ -7,7 +7,7 @@ import React, {memo, useEffect, useRef, useState} from 'react'; import {object, bool, number} from 'prop-types'; import BrowserInfo from '../../util/BrowserInfo.js'; import {EMPTY_BUNIT_DEFAULT} from '../FitsHeaderUtil'; -import {dispatchChangePointSelection} from '../ImagePlotCntlr.js'; +import {dispatchChangePointSelection} from '../ImagePlotDispatch'; import {showMouseReadoutFluxRadixDialog} from './MouseReadoutOptionPopups.jsx'; import {getNonFluxDisplayElements, getFluxInfo} from './MouseReadoutUIUtil.js'; import {CopyToClipboard} from './MouseReadout.jsx'; diff --git a/src/firefly/js/visualize/ui/MouseReadoutOptionPopups.jsx b/src/firefly/js/visualize/ui/MouseReadoutOptionPopups.jsx index 7f7f01bb8c..5c51db3b5c 100644 --- a/src/firefly/js/visualize/ui/MouseReadoutOptionPopups.jsx +++ b/src/firefly/js/visualize/ui/MouseReadoutOptionPopups.jsx @@ -27,8 +27,7 @@ import { MR_FITS_IP, MR_GALACTIC, MR_PIXEL_SIZE, MR_SPIXEL_SIZE, MR_SUPER_GALACTIC, MR_ZERO_IP, } from '../MouseReadoutCntlr'; import {dispatchShowDialog, dispatchHideDialog} from '../../core/ComponentCntlr.js'; -import {primePlot} from '../PlotViewUtil.js'; -import {visRoot} from '../ImagePlotCntlr.js'; +import {currentP} from '../PlotViewUtil.js'; import {isCelestialImage, isHiPS} from '../WebPlot.js'; //define the labels and values for the radio options @@ -85,7 +84,7 @@ function getNoncelestialCoordOptions(noncelestialOptionTitle='WCS Coordinates') } export function showMouseReadoutOptionDialog(fieldKey, radioValue, copyOptionValue, title='Choose Option', noncelestialOptionTitle=undefined) { - const plot = primePlot(visRoot()); + const {plot} = currentP(); const popup = ( obj ? {value:makeWLReturn(obj.value, getFormattedWav * @param plotId */ function createWCSCoordsLabel(plotId) { - const plot = primePlot(visRoot(), plotId); + const {plot} = currentP(plotId); const header = plot?.projection?.header; if (!header) return undefined; diff --git a/src/firefly/js/visualize/ui/MultiImageViewer.jsx b/src/firefly/js/visualize/ui/MultiImageViewer.jsx index d9612c18ce..aa124576dc 100644 --- a/src/firefly/js/visualize/ui/MultiImageViewer.jsx +++ b/src/firefly/js/visualize/ui/MultiImageViewer.jsx @@ -7,15 +7,15 @@ import {bool, number, string, func, elementType} from 'prop-types'; import {isEmpty} from 'lodash'; import {flux} from '../../core/ReduxFlux.js'; import { - NewPlotMode, dispatchAddViewer, dispatchViewerUnmounted, - getMultiViewRoot, getViewer, getLayoutType, findViewerWithItemId, IMAGE, + dispatchAddViewer, dispatchViewerUnmounted, + getMultiViewRoot, getViewer, getLayoutType, findViewerWithItemId, } from '../MultiViewCntlr.js'; import {MultiImageViewerView} from './MultiImageViewerView.jsx'; -import {visRoot, dispatchChangeActivePlotView} from '../ImagePlotCntlr.js'; -import {getDlAry} from '../DrawLayerCntlr.js'; -import {getPlotViewById, getPlotViewProxyById} from '../PlotViewUtil.js'; +import {dispatchChangeActivePlotView} from '../ImagePlotDispatch'; +import {IMAGE, NewPlotMode} from '../VisConst'; +import {getDlAry, visRoot} from '../VisStoreRoots'; +import {currentP, getPlotViewById, getPlotViewProxyById} from '../PlotViewUtil.js'; import {RenderTreeIdCtx} from '../../ui/RenderTreeIdCtx.jsx'; -import {getActivePlotView} from '../PlotViewUtil'; const activeViewerMap= new Map(); @@ -60,14 +60,14 @@ export class MultiImageViewer extends PureComponent {//todo: turn this into a fu } } - const pv= getActivePlotView(visRoot()); + const {pv}= currentP(); const viewer = getViewer(getMultiViewRoot(), props.viewerId); const {rootWidget}= this; if (!pv || !viewer || !rootWidget || !viewer.lastActiveItemId) return; activeViewerMap.set(this.props.viewerId, Boolean(rootWidget.offsetWidth && rootWidget.offsetHeight)); if (viewer.lastActiveItemId!==pv.plotId && !viewer.itemIdAry.includes(pv.plotId) && rootWidget.offsetWidth && rootWidget.offsetHeight) { setTimeout(() => { - if (!viewWithIdMounted(pv.plotId) && !viewer.itemIdAry.includes(getActivePlotView(visRoot())?.plotId)) { + if (!viewWithIdMounted(pv.plotId) && !viewer.itemIdAry.includes(currentP().plotId)) { dispatchChangeActivePlotView(viewer.lastActiveItemId); } }, 5); diff --git a/src/firefly/js/visualize/ui/MultiImageViewerView.jsx b/src/firefly/js/visualize/ui/MultiImageViewerView.jsx index 733cfe02f3..cd9055cd85 100644 --- a/src/firefly/js/visualize/ui/MultiImageViewerView.jsx +++ b/src/firefly/js/visualize/ui/MultiImageViewerView.jsx @@ -7,8 +7,9 @@ import React, {useRef} from 'react'; import {object, arrayOf, bool, func, number, oneOf, string, elementType, any} from 'prop-types'; import {omit} from 'lodash'; import {checkProps} from '../../ui/SimpleComponent'; -import {SINGLE, GRID, getMultiViewRoot, getViewer} from '../MultiViewCntlr.js'; +import {getMultiViewRoot, getViewer} from '../MultiViewCntlr.js'; import {getPlotViewById, getPlotViewProxyById, primePlot} from '../PlotViewUtil.js'; +import {GRID, SINGLE} from '../VisConst'; import {MultiItemViewerView} from './MultiItemViewerView.jsx'; import {ImageViewer, ImageViewerPlaceHolder} from '../iv/ImageViewer'; import {useMouseStoreConnector} from 'firefly/visualize/ui/MouseStoreConnector.jsx'; diff --git a/src/firefly/js/visualize/ui/MultiItemViewerView.jsx b/src/firefly/js/visualize/ui/MultiItemViewerView.jsx index 196a31f40a..a7929bea7b 100644 --- a/src/firefly/js/visualize/ui/MultiItemViewerView.jsx +++ b/src/firefly/js/visualize/ui/MultiItemViewerView.jsx @@ -7,8 +7,8 @@ import {debounce} from 'lodash'; import React, {useEffect, useRef, useState} from 'react'; import {bool, number, string, object, func, oneOf, arrayOf, any} from 'prop-types'; import {checkProps} from '../../ui/SimpleComponent'; -import {SINGLE, GRID} from '../MultiViewCntlr.js'; import {Divider, Stack} from '@mui/joy'; +import {GRID, SINGLE} from '../VisConst'; const flexContainerStyle= { display:'flex', diff --git a/src/firefly/js/visualize/ui/MultiViewStandardToolbar.jsx b/src/firefly/js/visualize/ui/MultiViewStandardToolbar.jsx index a7d21ca596..81100a5b41 100644 --- a/src/firefly/js/visualize/ui/MultiViewStandardToolbar.jsx +++ b/src/firefly/js/visualize/ui/MultiViewStandardToolbar.jsx @@ -9,10 +9,9 @@ import {Sheet, Stack} from '@mui/joy'; import {ToolbarHorizontalSeparator} from '../../ui/ToolbarButton.jsx'; import {HIDDEN} from '../ImViewFilterDisplay'; import {ViewerScroll} from '../iv/ExpandedTools.jsx'; -import { - dispatchChangeViewerLayout, EXPANDED_MODE_RESERVED, getMultiViewRoot, getViewer, getViewerItemIds -} from '../MultiViewCntlr.js'; -import {dispatchChangeActivePlotView} from '../ImagePlotCntlr.js'; +import {EXPANDED_MODE_RESERVED} from '../VisConst'; +import {dispatchChangeViewerLayout, getMultiViewRoot, getViewer, getViewerItemIds} from '../MultiViewCntlr.js'; +import {dispatchChangeActivePlotView} from '../ImagePlotDispatch'; import {BeforeButton, DisplayTypeButtonGroup, NextButton } from './Buttons.jsx'; import {ViewOptionsButton} from './ExpandedOptionsPopup.jsx'; import {VisMiniToolbar} from './VisMiniToolbar.jsx'; diff --git a/src/firefly/js/visualize/ui/PlotInfoPopup.js b/src/firefly/js/visualize/ui/PlotInfoPopup.js index f6e1bdfa8b..d43ae7b29e 100644 --- a/src/firefly/js/visualize/ui/PlotInfoPopup.js +++ b/src/firefly/js/visualize/ui/PlotInfoPopup.js @@ -1,9 +1,9 @@ import {isHiPS, isImage} from 'firefly/visualize/WebPlot.js'; -import {getActivePlotView, primePlot} from 'firefly/visualize/PlotViewUtil.js'; +import {currentP, primePlot} from 'firefly/visualize/PlotViewUtil.js'; import {FITS_HEADER_POPUP_ID, fitsHeaderView} from 'firefly/visualize/ui/FitsHeaderView.jsx'; import {HIPS_PROPERTY_POPUP_ID, showHiPSPropertyView} from 'firefly/visualize/ui/HiPSPropertyView.jsx'; import ComponentCntlr, {dispatchHideDialog, isDialogVisible} from 'firefly/core/ComponentCntlr.js'; -import ImagePlotCntlr, {visRoot} from 'firefly/visualize/ImagePlotCntlr.js'; +import {CHANGE_ACTIVE_PLOT_VIEW, CHANGE_PRIME_PLOT, DELETE_PLOT_VIEW, PLOT_HIPS, PLOT_IMAGE} from '../VisConst'; import {dispatchAddActionWatcher} from 'firefly/core/MasterSaga.js'; @@ -21,12 +21,8 @@ export function showPlotInfoPopup(pv, element) { dispatchAddActionWatcher( { id: 'hips-image-info-id', - actions: [ImagePlotCntlr.CHANGE_ACTIVE_PLOT_VIEW, - ImagePlotCntlr.CHANGE_PRIME_PLOT, - ImagePlotCntlr.PLOT_IMAGE, - ImagePlotCntlr.PLOT_HIPS, - ComponentCntlr.HIDE_DIALOG, - ImagePlotCntlr.DELETE_PLOT_VIEW], + actions: [CHANGE_ACTIVE_PLOT_VIEW, CHANGE_PRIME_PLOT, PLOT_IMAGE, PLOT_HIPS, + ComponentCntlr.HIDE_DIALOG, DELETE_PLOT_VIEW], callback: watchActivePlotChange, params: {element} }); @@ -49,10 +45,9 @@ const watchActivePlotChange = (action, cancelSelf, params) => { else { hideExternal=true; } - const pv= getActivePlotView(visRoot()); - const crtPlot = primePlot(visRoot()); + const {pv,plot:crtPlot}= currentP(); - if (action.type===ImagePlotCntlr.PLOT_IMAGE || action.type===ImagePlotCntlr.PLOT_HIPS || displayedPlotId!==crtPlot?.plotId ) { + if (action.type===PLOT_IMAGE || action.type===PLOT_HIPS || displayedPlotId!==crtPlot?.plotId ) { if (isHiPS(crtPlot) || lastType!==crtPlot?.plotType) { if (isDialogVisible(FITS_HEADER_POPUP_ID)) { dispatchHideDialog(FITS_HEADER_POPUP_ID); diff --git a/src/firefly/js/visualize/ui/PvControlsAndFeedback.jsx b/src/firefly/js/visualize/ui/PvControlsAndFeedback.jsx index b1d8de6308..9a62e69489 100644 --- a/src/firefly/js/visualize/ui/PvControlsAndFeedback.jsx +++ b/src/firefly/js/visualize/ui/PvControlsAndFeedback.jsx @@ -10,8 +10,8 @@ import {showInfoPopup} from '../../ui/PopupUtil'; import {checkProps} from '../../ui/SimpleComponent'; import {PlotAttribute} from '../PlotAttribute'; import {makeMouseStatePayload, fireMouseCtxChange, MouseState} from '../VisMouseSync.js'; -import {dispatchDeletePlotView, visRoot} from '../ImagePlotCntlr.js'; -import {primePlot, pvEqualExScroll} from '../PlotViewUtil.js'; +import {dispatchDeletePlotView} from '../ImagePlotDispatch'; +import {currentP, pvEqualExScroll} from '../PlotViewUtil.js'; import shallowequal from 'shallowequal'; import {WarningButton} from './Buttons'; @@ -64,7 +64,7 @@ export const PvControlsAndFeedback = memo( (props) => { function getWarningsAry(pv) { - const warnings= primePlot(visRoot(),pv.plotId)?.attributes[PlotAttribute.USER_WARNINGS] ?? {}; + const warnings= currentP(pv.plotId).plot?.attributes[PlotAttribute.USER_WARNINGS] ?? {}; if (isString(warnings)) { return [{warnings}]; } @@ -76,7 +76,7 @@ function getWarningsAry(pv) { function WarningsAlert({pv}) { - const warnings= primePlot(visRoot(),pv.plotId)?.attributes[PlotAttribute.USER_WARNINGS] ?? {}; + const warnings= currentP(pv.plotId).plot?.attributes[PlotAttribute.USER_WARNINGS] ?? {}; const defaultTip= isString(warnings) ? warnings : 'click for warnings'; const warnAry= getWarningsAry(pv); if (!warnAry?.length) return; diff --git a/src/firefly/js/visualize/ui/SelectAreaUIComponents.jsx b/src/firefly/js/visualize/ui/SelectAreaUIComponents.jsx index 881db7661a..7b0d1bcb2a 100644 --- a/src/firefly/js/visualize/ui/SelectAreaUIComponents.jsx +++ b/src/firefly/js/visualize/ui/SelectAreaUIComponents.jsx @@ -9,17 +9,14 @@ import {once} from 'lodash'; import {SingleColumnMenu} from '../../ui/DropDownMenu.jsx'; import {checkProps, useStoreConnector} from '../../ui/SimpleComponent'; import {ToolbarButton, DropDownVerticalSeparator} from '../../ui/ToolbarButton.jsx'; +import {dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDetachLayerFromPlot} from '../DrawLayerDispatch'; import { - getActivePlotView, getDrawLayerByType, getDrawLayersByType, getPlotViewAry, isDrawLayerAttached + currentP, getDrawLayerByType, getDrawLayersByType, getPlotViewAry, isDrawLayerAttached } from '../PlotViewUtil.js'; -import {dispatchCreateDrawLayer, - getDlAry, - dispatchAttachLayerToPlot, - dispatchDetachLayerFromPlot} from '../DrawLayerCntlr.js'; import SelectArea from '../../drawingLayers/SelectArea.js'; import ImageOutline from '../../drawingLayers/ImageOutline.js'; import {SelectedShape} from '../../drawingLayers/SelectedShape'; -import {visRoot} from '../ImagePlotCntlr.js'; +import {getDlAry, visRoot} from '../VisStoreRoots'; import {onOff, SimpleLayerOnOffButton} from 'firefly/visualize/ui/SimpleLayerOnOffButton.jsx'; import AdsClickIcon from '@mui/icons-material/AdsClick'; @@ -200,7 +197,7 @@ export function SelectAreaForEmbedded(props) { checkProps(props, SelectAreaForEmbedded); const modalEndInfo = useStoreConnector(() => getModalEndInfo()); const selectActive= modalEndInfo?.key==='SelectArea'; - const doSelection= updateSelect(getActivePlotView(visRoot()), shape.key, true, modalEndInfo); + const doSelection= updateSelect(currentP().pv, shape.key, true, modalEndInfo); return ( @@ -216,7 +213,7 @@ export function SelectAreaForEmbedded(props) { { - const pv = getActivePlotView(visRoot()); + const {pv} = currentP(); if (pv) dispatchDetachLayerFromPlot(SelectArea.TYPE_ID, pv.plotId, true, true); clearModalEndInfo(); } diff --git a/src/firefly/js/visualize/ui/SimpleLayerOnOffButton.jsx b/src/firefly/js/visualize/ui/SimpleLayerOnOffButton.jsx index f282ffbc80..04148281e0 100644 --- a/src/firefly/js/visualize/ui/SimpleLayerOnOffButton.jsx +++ b/src/firefly/js/visualize/ui/SimpleLayerOnOffButton.jsx @@ -5,13 +5,11 @@ // import FlipOutlinedIcon from '@mui/icons-material/FlipOutlined.js'; import React from 'react'; import PropTypes, {bool, element, object, oneOfType, string} from 'prop-types'; +import {dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDetachLayerFromPlot} from '../DrawLayerDispatch'; import {getDrawLayerByType, isDrawLayerAttached, primePlot } from '../PlotViewUtil.js'; import {ToolbarButton} from '../../ui/ToolbarButton.jsx'; import {DropDownToolbarButton} from '../../ui/DropDownToolbarButton.jsx'; -import {dispatchCreateDrawLayer, - getDlAry, - dispatchAttachLayerToPlot, - dispatchDetachLayerFromPlot} from '../DrawLayerCntlr.js'; +import {getDlAry} from '../VisStoreRoots'; import {clearModalEndInfo, setModalEndInfo} from './ToolbarToolModalEnd.js'; diff --git a/src/firefly/js/visualize/ui/SmallLegend.jsx b/src/firefly/js/visualize/ui/SmallLegend.jsx index 9b7a4703e4..0c89938545 100644 --- a/src/firefly/js/visualize/ui/SmallLegend.jsx +++ b/src/firefly/js/visualize/ui/SmallLegend.jsx @@ -10,10 +10,10 @@ import HiPSMOC from '../../drawingLayers/HiPSMOC.js'; import {CollapsibleItem} from '../../ui/panel/CollapsiblePanel'; import {useStoreConnector} from '../../ui/SimpleComponent'; import BrowserInfo from '../../util/BrowserInfo'; -import {getDlAry} from '../DrawLayerCntlr'; import { getAllDrawLayersForPlot, getLayerTitle, getPlotViewById, isDrawLayerVisible, primePlot } from '../PlotViewUtil'; +import {getDlAry} from '../VisStoreRoots'; import {isHiPS} from '../WebPlot'; import {DrawLayerLegendView} from './DrawLayerItemView'; import {showDrawingLayerPopup} from './DrawLayerPanel'; diff --git a/src/firefly/js/visualize/ui/StretchDropDownView.jsx b/src/firefly/js/visualize/ui/StretchDropDownView.jsx index 5a4f4f5cea..b9477c84b3 100644 --- a/src/firefly/js/visualize/ui/StretchDropDownView.jsx +++ b/src/firefly/js/visualize/ui/StretchDropDownView.jsx @@ -4,11 +4,11 @@ import React from 'react'; import PropTypes from 'prop-types'; -import {getActivePlotView, primePlot} from '../PlotViewUtil.js'; +import {currentP, primePlot} from '../PlotViewUtil.js'; import { RangeValues} from '../RangeValues.js'; import {SingleColumnMenu} from '../../ui/DropDownMenu.jsx'; import { ToolbarButton, DropDownVerticalSeparator} from '../../ui/ToolbarButton.jsx'; -import {dispatchStretchChange, visRoot} from '../ImagePlotCntlr.js'; +import {dispatchStretchChange} from '../ImagePlotDispatch'; import { PERCENTAGE, ZSCALE, SIGMA, STRETCH_LINEAR, STRETCH_LOG, STRETCH_LOGLOG, STRETCH_EQUAL, STRETCH_SQUARED, STRETCH_SQRT, STRETCH_ASINH, STRETCH_POWERLAW_GAMMA, } from '../RangeValues.js'; import {showColorDialog} from './ColorDialog.jsx'; @@ -74,9 +74,8 @@ function stretchByType(pv,currRV,sType,lowerValue,upperValue,asinhQ) { export function StretchDropDownView({toolbarElement}) { - const pv = useStoreConnector(() => getActivePlotView(visRoot())); + const {pv,plot} = useStoreConnector(() => currentP()); const enabled= Boolean(pv); - const plot= primePlot(pv); if (!plot) return
; const rv= plot?.plotState?.getRangeValues(); diff --git a/src/firefly/js/visualize/ui/TargetHiPSPanel.jsx b/src/firefly/js/visualize/ui/TargetHiPSPanel.jsx index 448d5450d5..5b91530c1b 100644 --- a/src/firefly/js/visualize/ui/TargetHiPSPanel.jsx +++ b/src/firefly/js/visualize/ui/TargetHiPSPanel.jsx @@ -28,20 +28,17 @@ import {DEF_TARGET_PANEL_KEY, TargetPanel} from '../../ui/TargetPanel.jsx'; import {parseObsCoreRegion} from '../../util/ObsCoreSRegionParser.js'; import {callWhileAwaiting} from '../../util/WebUtil'; import {CoordinateSys} from '../CoordSys.js'; +import {dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDestroyDrawLayer} from '../DrawLayerDispatch'; import { - dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDestroyDrawLayer, dlRoot, getDlAry -} from '../DrawLayerCntlr.js'; -import { - dispatchChangeActivePlotView, dispatchChangeHiPS, dispatchDeletePlotView, dispatchPlotHiPS, visRoot -} from '../ImagePlotCntlr.js'; -import {NewPlotMode} from '../MultiViewCntlr.js'; + dispatchChangeActivePlotView, dispatchChangeHiPS, dispatchDeletePlotView, dispatchPlotHiPS +} from '../ImagePlotDispatch'; +import {NewPlotMode} from '../VisConst'; import {PlotAttribute} from '../PlotAttribute'; import {onPlotComplete} from '../PlotCompleteMonitor.js'; -import { - getActivePlotView, getDrawLayersByType, getPlotViewById, isDrawLayerAttached, primePlot -} from '../PlotViewUtil.js'; +import {currentP, getDrawLayersByType, isDrawLayerAttached, primePlot} from '../PlotViewUtil.js'; import {makeWorldPt, parseWorldPt} from '../Point.js'; import {createHiPSMocLayerFromPreloadedTable} from '../task/PlotHipsTask.js'; +import {dlRoot, getDlAry} from '../VisStoreRoots'; import {WebPlotRequest} from '../WebPlotRequest.js'; import {BOX_CHOICE_KEY, CONE_CHOICE_KEY, POLY_CHOICE_KEY} from './CommonUIKeys.js'; import {MultiImageViewer} from './MultiImageViewer.jsx'; @@ -123,7 +120,7 @@ export const HiPSTargetView = ({sx, hipsDisplayKey='none', const viewerId= plotId+'-viewer'; - const pv= useStoreConnector(() => getPlotViewById(visRoot(),plotId)); + const pv= useStoreConnector(() => currentP(plotId).pv); const [getTargetWp,setTargetWp]= useFieldGroupValue(targetKey, groupKey); const [getHiPSRadius, setHiPSRadius]= useFieldGroupValue(sizeKey, groupKey); const [getPolygon, setPolygon]= useFieldGroupValue(polygonKey, groupKey); @@ -168,7 +165,7 @@ export const HiPSTargetView = ({sx, hipsDisplayKey='none', updatePlotOverlayFromUserInput({plotId, whichOverlay: getWhichOverlay(), wp: userEnterWorldPt(), radius: userEnterSearchRadius(), polygonAry: userEnterPolygon(), boxParams: userEnterBoxParams(), forceCenterOn: true}); - if (getActivePlotView(visRoot())?.plotId !== plotId ) dispatchChangeActivePlotView(plotId); + if (currentP().plotId !== plotId ) dispatchChangeActivePlotView(plotId); } return () => { if (cleanup) dispatchDeletePlotView({plotId}); @@ -196,7 +193,7 @@ export const HiPSTargetView = ({sx, hipsDisplayKey='none', const whichOverlay= getWhichOverlay(); const canGenerate= whichOverlay!==lastWhichOverlay.lastValue; if (canGenerate && (whichOverlay===CONE_CHOICE_KEY || whichOverlay===BOX_CHOICE_KEY) && !userEnterWorldPt()) { - const wp = primePlot(visRoot(), plotId)?.attributes[PlotAttribute.USER_SEARCH_WP]; + const wp = currentP(plotId).plot?.attributes[PlotAttribute.USER_SEARCH_WP]; wp && setTargetWp(wp.toString()); } const radius= usingRadius ? userEnterSearchRadius() : undefined; diff --git a/src/firefly/js/visualize/ui/TargetHipsPanelToolbar.jsx b/src/firefly/js/visualize/ui/TargetHipsPanelToolbar.jsx index 94cd98db97..3a18386182 100644 --- a/src/firefly/js/visualize/ui/TargetHipsPanelToolbar.jsx +++ b/src/firefly/js/visualize/ui/TargetHipsPanelToolbar.jsx @@ -4,8 +4,7 @@ import React from 'react'; import {dispatchComponentStateChange, getComponentState} from '../../core/ComponentCntlr.js'; import HelpIcon from '../../ui/HelpIcon.jsx'; import {useStoreConnector} from '../../ui/SimpleComponent.jsx'; -import {visRoot} from '../ImagePlotCntlr.js'; -import {getActivePlotView} from '../PlotViewUtil.js'; +import {currentP} from '../PlotViewUtil.js'; import {BOX_CHOICE_KEY, CONE_CHOICE_KEY} from './CommonUIKeys.js'; import {SelectAreaButton} from './SelectAreaUIComponents.jsx'; import {VisMiniToolbar} from './VisMiniToolbar.jsx'; @@ -24,7 +23,7 @@ export const HelpLines= ({whichOverlay, selectionHelpText, usingRadius}) => { const imageStyle={width:16, height:16}; const selectButton= ( - ); @@ -66,10 +65,10 @@ export const HelpLines= ({whichOverlay, selectionHelpText, usingRadius}) => { }; -export function TargetHipsPanelToolbar({visRoot, toolbarStyle={}, +export function TargetHipsPanelToolbar({toolbarStyle={}, whichOverlay= CONE_CHOICE_KEY, viewerId, menuItemKeys, toolbarHelpId='hips.VisualSelection'}) { - const {showImageToolbar=true}= getActivePlotView(visRoot)?.plotViewCtx.menuItemKeys ?? {}; + const {showImageToolbar=true}= currentP().pv?.plotViewCtx.menuItemKeys ?? {}; if (!showImageToolbar) return
; return ( @@ -87,7 +86,6 @@ export function TargetHipsPanelToolbar({visRoot, toolbarStyle={}, TargetHipsPanelToolbar.propTypes= { dlAry : PropTypes.arrayOf(PropTypes.object), - visRoot : PropTypes.object, viewerId : PropTypes.string.isRequired, layoutType : PropTypes.string, makeDropDownFunc: PropTypes.func, diff --git a/src/firefly/js/visualize/ui/ThumbnailView.jsx b/src/firefly/js/visualize/ui/ThumbnailView.jsx index fb7cddb308..0d0c6f99b2 100644 --- a/src/firefly/js/visualize/ui/ThumbnailView.jsx +++ b/src/firefly/js/visualize/ui/ThumbnailView.jsx @@ -15,7 +15,7 @@ import {COLOR_DRAW_1, COLOR_DRAW_2,Style} from '../draw/DrawingDef.js'; import {hasLocalStretchByteData, primePlot} from '../PlotViewUtil.js'; import {EventLayer} from '../iv/EventLayer.jsx'; import {MouseState} from '../VisMouseSync.js'; -import {dispatchProcessScroll} from '../ImagePlotCntlr.js'; +import {dispatchProcessScroll} from '../ImagePlotDispatch'; import {makeMouseStatePayload,fireMouseCtxChange} from '../VisMouseSync.js'; import {makeTransform,makeThumbnailTransformCSS} from '../PlotTransformUtils.js'; import {findScrollPtToCenterImagePt} from '../reducer/PlotView.js'; diff --git a/src/firefly/js/visualize/ui/TriViewImageSection.jsx b/src/firefly/js/visualize/ui/TriViewImageSection.jsx index deadcc2250..8460d4b3a2 100644 --- a/src/firefly/js/visualize/ui/TriViewImageSection.jsx +++ b/src/firefly/js/visualize/ui/TriViewImageSection.jsx @@ -6,6 +6,7 @@ import {Badge} from '@mui/joy'; import React from 'react'; import PropTypes from 'prop-types'; import {isEmpty} from 'lodash'; +import {REINIT_APP} from '../../core/CoreConst'; import {useStoreConnector} from '../../ui/SimpleComponent.jsx'; import { hasCoverageData, isCatalog, isDataProductsTable, isObsCoreLike, isOrbitalPathTable @@ -18,23 +19,19 @@ import {Tab, TabPanel} from '../../ui/panel/TabPanel.jsx'; import {MultiViewStandardToolbar} from './MultiViewStandardToolbar.jsx'; import {MultiImageViewer} from './MultiImageViewer.jsx'; import {dispatchAddActionWatcher} from '../../core/MasterSaga.js'; -import { - DEFAULT_FITS_VIEWER_ID, REPLACE_VIEWER_ITEMS, NewPlotMode, getViewerItemIds, getMultiViewRoot, - META_VIEWER_ID} from '../MultiViewCntlr.js'; +import {getViewerItemIds, getMultiViewRoot} from '../MultiViewCntlr.js'; import { getTblById, findGroupByTblId, getTblIdsByGroup, smartMerge, getActiveTableId, getColumnIdx } from '../../tables/TableUtil.js'; import { - LO_MODE, - LO_VIEW, - dispatchSetLayoutMode, - dispatchUpdateLayoutInfo, - getLayouInfo, - TAB_IDS + LO_MODE, LO_VIEW, dispatchSetLayoutMode, dispatchUpdateLayoutInfo, getLayouInfo, TAB_IDS } from '../../core/LayoutCntlr.js'; -import ImagePlotCntlr, {visRoot} from '../../visualize/ImagePlotCntlr.js'; +import { + DEFAULT_FITS_VIEWER_ID, DELETE_PLOT_VIEW, META_VIEWER_ID, NewPlotMode, + PLOT_HIPS, PLOT_IMAGE, PLOT_IMAGE_START, REPLACE_VIEWER_ITEMS +} from '../VisConst'; +import {visRoot} from '../VisStoreRoots'; import {TABLE_HIGHLIGHT, TABLE_LOADED, TBL_RESULTS_ACTIVE, TBL_RESULTS_ADDED} from '../../tables/TablesCntlr.js'; -import {REINIT_APP} from '../../core/AppDataCntlr.js'; import {MetaDataMultiProductViewer} from './multiProduct/MetaDataMultiProductViewer.jsx'; import {CoverageViewer} from './CoveraeViewer'; import {getPlotViewAry} from 'firefly/visualize/PlotViewUtil.js'; @@ -165,8 +162,8 @@ function getDefSelected(showCoverage, showFits, showMeta, tbl_id) { export function startImagesLayoutWatcher() { const actions = [ - ImagePlotCntlr.PLOT_IMAGE_START, ImagePlotCntlr.PLOT_IMAGE, ImagePlotCntlr.PLOT_HIPS, - ImagePlotCntlr.DELETE_PLOT_VIEW, REPLACE_VIEWER_ITEMS,TABLE_HIGHLIGHT, + PLOT_IMAGE_START, PLOT_IMAGE, PLOT_HIPS, + DELETE_PLOT_VIEW, REPLACE_VIEWER_ITEMS,TABLE_HIGHLIGHT, TBL_RESULTS_ACTIVE, TABLE_LOADED, TBL_RESULTS_ADDED, REINIT_APP ]; @@ -178,7 +175,6 @@ export function startImagesLayoutWatcher() { * Action watcher callback: manages layout info related to this component. * @callback actionWatcherCallback * @param action - * @param cancelSelf */ function layoutHandler(action) { @@ -197,13 +193,13 @@ function layoutHandler(action) { let newLayoutInfo = layoutInfo; switch (action.type) { - case ImagePlotCntlr.PLOT_IMAGE_START: - case ImagePlotCntlr.PLOT_IMAGE : - case ImagePlotCntlr.PLOT_HIPS: + case PLOT_IMAGE_START: + case PLOT_IMAGE : + case PLOT_HIPS: case REPLACE_VIEWER_ITEMS: newLayoutInfo = onNewImage(newLayoutInfo, action); break; - case ImagePlotCntlr.DELETE_PLOT_VIEW: + case DELETE_PLOT_VIEW: newLayoutInfo = onPlotDelete(newLayoutInfo, action); break; case TABLE_LOADED: diff --git a/src/firefly/js/visualize/ui/VisCtxToolbarView.jsx b/src/firefly/js/visualize/ui/VisCtxToolbarView.jsx index ba826c7b5d..762880573d 100644 --- a/src/firefly/js/visualize/ui/VisCtxToolbarView.jsx +++ b/src/firefly/js/visualize/ui/VisCtxToolbarView.jsx @@ -24,14 +24,13 @@ import Validate from '../../util/Validate.js'; import {CoordinateSys} from '../CoordSys.js'; import {getExtName, getExtType, getHeader} from '../FitsHeaderUtil.js'; import { - dispatchChangeCenterOfProjection, dispatchChangeHiPS, dispatchChangeHipsImageConversion, dispatchChangePrimePlot, - visRoot -} from '../ImagePlotCntlr.js'; + dispatchChangeCenterOfProjection, dispatchChangeHiPS, dispatchChangeHipsImageConversion, dispatchChangePrimePlot +} from '../ImagePlotDispatch'; import {PlotAttribute} from '../PlotAttribute'; import { - canConvertBetweenHipsAndFits, convertHDUIdxToImageIdx, convertImageIdxToHDU, getActivePlotView, getCubePlaneCnt, - getFormattedWaveLengthUnits, getHDU, getHDUCount, getHDUIndex, getPlotViewById, getPtWavelength, hasPlaneOnlyWLInfo, - isImageCube, isMultiHDUFits, primePlot, pvEqualExScroll, + canConvertBetweenHipsAndFits, convertHDUIdxToImageIdx, convertImageIdxToHDU, currentP, getCubePlaneCnt, + getFormattedWaveLengthUnits, getHDU, getHDUCount, getHDUIndex, getPtWavelength, + hasPlaneOnlyWLInfo, isImageCube, isMultiHDUFits, primePlot, pvEqualExScroll, refreshP, } from '../PlotViewUtil.js'; import {makeWorldPt} from '../Point.js'; import {convertToHiPS, convertToImage, doHiPSImageConversionIfNecessary} from '../task/PlotHipsTask.js'; @@ -56,7 +55,7 @@ function makeExtensionButtons(extensionAry,pv) { tip={ext.toolTip} key={ext.id} shortcutKey={ext.shortcutKey} lastTextItem={idx===(extensionAry.length-1)} onClick={() => { - if (getActivePlotView(visRoot())?.plotId===pv.plotId) { + if (currentP().plotId===pv.plotId) { dispatchExtensionActivate(ext,makePlotSelectionExtActivateData(ext,pv)); } }}/> @@ -84,7 +83,7 @@ function doHiPSFitsConvert(pv,target) { function changeAutoConvert(pv, auto) { dispatchChangeHipsImageConversion({plotId:pv.plotId, hipsImageConversionChanges:{autoConvertOnZoom:auto}}); - const nextPv= getPlotViewById(visRoot(), pv.plotId); + const nextPv= refreshP(pv); if (auto) doHiPSImageConversionIfNecessary(nextPv); } diff --git a/src/firefly/js/visualize/ui/VisMiniToolbar.jsx b/src/firefly/js/visualize/ui/VisMiniToolbar.jsx index 110ae272e6..f9c54acbe4 100644 --- a/src/firefly/js/visualize/ui/VisMiniToolbar.jsx +++ b/src/firefly/js/visualize/ui/VisMiniToolbar.jsx @@ -34,11 +34,12 @@ import {StretchDropDownView} from 'firefly/visualize/ui/StretchDropDownView.jsx' import {isHiPS} from 'firefly/visualize/WebPlot.js'; import {getPreference} from '../../core/AppDataCntlr.js'; import {useStoreConnector} from '../../ui/SimpleComponent.jsx'; -import {getDlAry} from '../DrawLayerCntlr.js'; import { - dispatchChangeActivePlotView, dispatchChangeExpandedMode, dispatchChangeHiPS, dispatchFlip, - dispatchRestoreDefaults, dispatchRotate, ExpandType, visRoot -} from '../ImagePlotCntlr.js'; + dispatchChangeActivePlotView, dispatchChangeExpandedMode, dispatchChangeHiPS, dispatchFlip, dispatchRestoreDefaults, + dispatchRotate +} from '../ImagePlotDispatch'; +import {ExpandType} from '../VisConst'; +import {getDlAry, visRoot} from '../VisStoreRoots'; import {getMultiViewRoot, getViewer} from '../MultiViewCntlr.js'; import { getActivePlotView, getAllDrawLayersForPlot, getPlotViewById, hasWCSProjection, diff --git a/src/firefly/js/visualize/ui/VisualSearchUtils.js b/src/firefly/js/visualize/ui/VisualSearchUtils.js index 327d503ccd..b96b357d2c 100644 --- a/src/firefly/js/visualize/ui/VisualSearchUtils.js +++ b/src/firefly/js/visualize/ui/VisualSearchUtils.js @@ -9,27 +9,21 @@ import {splitByWhiteSpace} from '../../util/WebUtil.js'; import CsysConverter, {CysConverter} from '../CsysConverter.js'; import { dispatchAttachLayerToPlot, dispatchChangeDrawingDef, dispatchCreateDrawLayer, dispatchDestroyDrawLayer, - dispatchForceDrawLayerUpdate, dispatchModifyCustomField, getDlAry -} from '../DrawLayerCntlr.js'; -import {dispatchAttributeChange, dispatchChangeCenterOfProjection, visRoot} from '../ImagePlotCntlr.js'; + dispatchForceDrawLayerUpdate, + dispatchModifyCustomField +} from '../DrawLayerDispatch'; +import {dispatchAttributeChange, dispatchChangeCenterOfProjection} from '../ImagePlotDispatch'; +import {getDlAry, visRoot} from '../VisStoreRoots'; import {PlotAttribute} from '../PlotAttribute.js'; import {getDrawLayerByType, getPlotViewById, isDrawLayerAttached, primePlot} from '../PlotViewUtil.js'; import {isValidPoint, makeDevicePt, makeImagePt, makeWorldPt, parseWorldPt, pointEquals} from '../Point.js'; import { - calculatePosition, - calculatePositionFromLocalOffsets, - computeCentralPointAndRadius, - computeDistance, - convertCelestial, - getPointOnEllipse, - getPositionAngle, - normalizeRotation, + calculatePosition, calculatePositionFromLocalOffsets, computeCentralPointAndRadius, computeDistance, + convertCelestial, getPointOnEllipse, getPositionAngle, normalizeRotation, } from '../VisUtil.js'; import {changeHiPSProjectionCenter, getDevPixScaleDeg, isImage} from '../WebPlot.js'; import {BOX_CHOICE_KEY, CONE_CHOICE_KEY, POLY_CHOICE_KEY} from './CommonUIKeys.js'; -import { - clearModalEndInfo, closeToolbarModalLayers, getModalEndInfo, setModalEndInfo -} from './ToolbarToolModalEnd.js'; +import {clearModalEndInfo, closeToolbarModalLayers, getModalEndInfo, setModalEndInfo} from './ToolbarToolModalEnd.js'; import {dispatchActiveTarget} from '../../core/AppDataCntlr.js'; import {clampInRange} from 'firefly/util/MathUtil'; diff --git a/src/firefly/js/visualize/ui/ZoomButton.jsx b/src/firefly/js/visualize/ui/ZoomButton.jsx index 76fcc7733b..b4b3a985d1 100644 --- a/src/firefly/js/visualize/ui/ZoomButton.jsx +++ b/src/firefly/js/visualize/ui/ZoomButton.jsx @@ -4,8 +4,9 @@ import React from 'react'; import PropTypes from 'prop-types'; -import {dispatchZoom} from '../ImagePlotCntlr.js'; -import {getZoomMax, getNextZoomLevel, UserZoomTypes, getZoomDesc} from '../ZoomUtil.js'; +import {dispatchZoom} from '../ImagePlotDispatch'; +import {UserZoomTypes} from '../VisConst'; +import {getZoomMax, getNextZoomLevel, getZoomDesc} from '../ZoomUtil.js'; import {primePlot} from '../PlotViewUtil.js'; import {showZoomOptionsPopup} from '../../ui/ZoomOptionsPopup.jsx'; import {showInfoPopup} from '../../ui/PopupUtil.jsx'; diff --git a/src/firefly/js/visualize/ui/extraction/ExtractionDialog.jsx b/src/firefly/js/visualize/ui/extraction/ExtractionDialog.jsx index 0e1f0e65ea..9b74d856ba 100644 --- a/src/firefly/js/visualize/ui/extraction/ExtractionDialog.jsx +++ b/src/firefly/js/visualize/ui/extraction/ExtractionDialog.jsx @@ -8,6 +8,10 @@ import {isUndefined} from 'lodash'; import React, {useEffect, useState} from 'react'; import {getAppOptions} from '../../../api/ApiUtil.js'; import {CHART_RESIZE_DEBOUNCE, wrapResizeMonitor} from '../../../ui/ResizeMonitor'; +import { + dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDestroyDrawLayer, dispatchDetachLayerFromPlot, + dispatchModifyCustomField +} from '../../DrawLayerDispatch'; import {makeImagePt} from '../../Point'; import {allowPinnedCharts} from '../../../charts/ChartUtil'; import {ensureDefaultChart} from '../../../charts/ui/ChartsContainer.jsx'; @@ -31,19 +35,15 @@ import {useFieldGroupValue, useStoreConnector} from '../../../ui/SimpleComponent import {ValidationField} from '../../../ui/ValidationField'; import {intValidator} from '../../../util/Validate'; import {CCUtil, CysConverter} from '../../CsysConverter.js'; -import { - dispatchAttachLayerToPlot, dispatchCreateDrawLayer, dispatchDestroyDrawLayer, dispatchDetachLayerFromPlot, - dispatchModifyCustomField, getDlAry -} from '../../DrawLayerCntlr.js'; import {getExtName, hasFloatingData} from '../../FitsHeaderUtil.js'; -import ImagePlotCntlr, { - dispatchAttributeChange, dispatchChangePointSelection, dispatchChangePrimePlot, visRoot -} from '../../ImagePlotCntlr.js'; +import {dispatchAttributeChange, dispatchChangePointSelection, dispatchChangePrimePlot} from '../../ImagePlotDispatch'; +import {PLOT_IMAGE} from '../../VisConst'; +import {getDlAry, visRoot} from '../../VisStoreRoots'; import {PlotAttribute} from '../../PlotAttribute.js'; import { - convertHDUIdxToImageIdx, getActivePlotView, getCubePlaneFromWavelength, getDrawLayerByType, getHDU, getHDUIndex, - getImageCubeIdx, getPlotViewAry, getPlotViewById, hasWCSProjection, hasWLInfo, isDrawLayerAttached, isImageCube, - isMultiHDUFits, primePlot + convertHDUIdxToImageIdx, currentP, getCubePlaneFromWavelength, getDrawLayerByType, getHDU, getHDUIndex, + getImageCubeIdx, getPlotViewAry, hasWCSProjection, hasWLInfo, isDrawLayerAttached, + isImageCube, isMultiHDUFits, primePlot } from '../../PlotViewUtil.js'; import {computeDistance, computeScreenDistance, getLinePointAry} from '../../VisUtil.js'; import {genPointChartData, genSliceChartData, genZAxisChartData} from './ExtractionChart.jsx'; @@ -82,7 +82,7 @@ const exTypeCntl= { function enableDrawLayer(typeId) { - const pv= getActivePlotView(visRoot()); + const {pv}= currentP(); const dl= getDrawLayerByType(getDlAry(), typeId); !dl && dispatchCreateDrawLayer(typeId); !isDrawLayerAttached(dl,pv.plotId) && dispatchAttachLayerToPlot(typeId,pv.plotId,true,true, true); @@ -101,7 +101,7 @@ export function showExtractionDialog(element,extractionType,wasCanceled) { dispatchAddActionWatcher( { id: EXTRACT_END_ID, callback: (action) => exTypeCntl[extractionType].start(), - actions:[ImagePlotCntlr.PLOT_IMAGE] + actions:[PLOT_IMAGE] }); } @@ -138,9 +138,12 @@ function ExtractDialog({extractionType,wasCanceled}) { function getStoreState(prevResult) { const vr= visRoot(); - const activePv= getActivePlotView(vr); - const pv= primePlot(activePv) ? activePv : - primePlot(vr, vr.prevActivePlotId) ? getPlotViewById(vr,vr.prevActivePlotId) : activePv; + const {pv:activePv}= currentP(); + const pv= primePlot(activePv) + ? activePv + : currentP(vr.prevActivePlotId).plot + ? currentP(vr.prevActivePlotId).pv + : activePv; const pvAry= pv ? getPlotViewAry(visRoot(), pv.plotGroupId) : []; if (prevResult && prevResult.pv===pv && prevResult.pvCnt===pvAry.length && primePlot(pv)===primePlot(prevResult.pv)) return prevResult; return {pv,pvCnt:pvAry.length}; @@ -696,7 +699,7 @@ function cancelZaxisExtraction() { } function cancelLineExtraction() { - const pv= getActivePlotView(visRoot()); + const {pv}= currentP(); if (pv) { dispatchDetachLayerFromPlot(ExtractLineTool.TYPE_ID,pv.plotId,true); dispatchAttributeChange({plotId:pv.plotId,overlayColorScope:true, @@ -707,7 +710,7 @@ function cancelLineExtraction() { } function cancelPointExtraction() { - const pv= getActivePlotView(visRoot()); + const {pv}= currentP(); if (pv) { dispatchDetachLayerFromPlot(ExtractPointsTool.TYPE_ID,pv.plotId,true); dispatchDestroyDrawLayer(ExtractPointsTool.TYPE_ID); diff --git a/src/firefly/js/visualize/ui/extraction/ExtractionTable.jsx b/src/firefly/js/visualize/ui/extraction/ExtractionTable.jsx index 3b37c23ba1..2265c710d2 100644 --- a/src/firefly/js/visualize/ui/extraction/ExtractionTable.jsx +++ b/src/firefly/js/visualize/ui/extraction/ExtractionTable.jsx @@ -13,7 +13,7 @@ import {useFieldGroupValue} from '../../../ui/SimpleComponent'; import {advancedTrim} from '../../../util/WebUtil'; import {CCUtil, CysConverter} from '../../CsysConverter'; import {getExtName} from '../../FitsHeaderUtil'; -import {visRoot} from '../../ImagePlotCntlr'; +import {visRoot} from '../../VisStoreRoots'; import { getAllWaveLengthsForCube, getHDU, getHduPlotStartIndexes, getImageCubeIdx, getPlotViewAry, getPtWavelength, getWaveLengthUnits, diff --git a/src/firefly/js/visualize/ui/multiProduct/MultiProductChoice.jsx b/src/firefly/js/visualize/ui/multiProduct/MultiProductChoice.jsx index ea2545ece7..906b1cb00d 100644 --- a/src/firefly/js/visualize/ui/multiProduct/MultiProductChoice.jsx +++ b/src/firefly/js/visualize/ui/multiProduct/MultiProductChoice.jsx @@ -8,9 +8,9 @@ import {TablesContainer} from '../../../tables/ui/TablesContainer.jsx'; import {RadioGroupInputFieldView} from '../../../ui/RadioGroupInputFieldView.jsx'; import {useStoreConnector} from '../../../ui/SimpleComponent'; import {ToolbarHorizontalSeparator} from '../../../ui/ToolbarButton'; -import {dispatchChangePrimePlot, visRoot} from '../../ImagePlotCntlr'; -import {NewPlotMode} from '../../MultiViewCntlr.js'; -import { convertHDUIdxToImageIdx, getActivePlotView, getHDUIndex, hasImageCubes} from '../../PlotViewUtil'; +import {dispatchChangePrimePlot} from '../../ImagePlotDispatch'; +import {NewPlotMode} from '../../VisConst'; +import {convertHDUIdxToImageIdx, currentP, getHDUIndex, hasImageCubes} from '../../PlotViewUtil'; import {ImageMetaDataToolbar} from '../ImageMetaDataToolbar.jsx'; import {MultiImageViewer} from '../MultiImageViewer.jsx'; import {SmallLegend} from '../SmallLegend'; @@ -29,7 +29,7 @@ export function MultiProductChoice({ dataProductsState, dpId, //handle null dataProductsState for cases where data products workflow is not used const {enableCutout, pixelBasedCutout=false, dlData, gridForceRowSize}= dataProductsState ?? {}; const {serDef, cutoutToFullWarning, dlAnalysis:{cutoutFullPair=false}={}}= dataProductsState?.dlData ?? {}; - const primeIdx= useStoreConnector(() => getActivePlotView(visRoot())?.primeIdx ?? -1); + const primeIdx= useStoreConnector(() => currentP().pv?.primeIdx ?? -1); const {current:showingStatus}= useRef({oldWhatToShow:undefined}); const stateDef= dlData ? dlData?.dlAnalysis?.isSpectrum ? 'Spectrum' : 'Chart' : lastChartDefault; const [chartName, setChartName] = useState(stateDef); @@ -52,7 +52,7 @@ export function MultiProductChoice({ dataProductsState, dpId, useEffect(() => { if (!imageViewerId) return; - const pv= getActivePlotView(visRoot()); + const {pv}= currentP(); if (!pv || !hasImageCubes(pv) || cubeIdx<0) return; showingStatus.oldWhatToShow= whatToShow; showingStatus.cubeSet= false; @@ -61,7 +61,7 @@ export function MultiProductChoice({ dataProductsState, dpId, useEffect(() => { if (!imageViewerId || primeIdx===-1 || cubeIdx<0) return; if (showingStatus.cubeSet) return; - const pv= getActivePlotView(visRoot()); + const {pv}= currentP(); if (!pv || !hasImageCubes(pv)) return; showingStatus.cubeSet= true; const hduIdx= getHDUIndex(pv); diff --git a/src/firefly/js/visualize/ui/multiProduct/MultiProductViewer.jsx b/src/firefly/js/visualize/ui/multiProduct/MultiProductViewer.jsx index d0b414cf2b..b78a3dda85 100644 --- a/src/firefly/js/visualize/ui/multiProduct/MultiProductViewer.jsx +++ b/src/firefly/js/visualize/ui/multiProduct/MultiProductViewer.jsx @@ -16,10 +16,8 @@ import {ServiceDescriptorPanel} from '../../../ui/dynamic/ServiceDescriptorPanel import {RenderTreeIdCtx} from '../../../ui/RenderTreeIdCtx.jsx'; import {useStoreConnector} from '../../../ui/SimpleComponent.jsx'; import {isDefined} from '../../../util/WebUtil'; -import { - dispatchAddViewer, dispatchViewerUnmounted, getLayoutDetails, getMultiViewRoot, GRID, IMAGE, NewPlotMode, - PLOT2D, SINGLE -} from '../../MultiViewCntlr.js'; +import {dispatchAddViewer, dispatchViewerUnmounted, getLayoutDetails, getMultiViewRoot} from '../../MultiViewCntlr.js'; +import {GRID, IMAGE, NewPlotMode, PLOT2D, SINGLE} from '../../VisConst'; import {createMakeDropdownFunc} from './DPDropdown.jsx'; import {AdvancedMessage, ProductDownload, ProductMessage, TextFileViewer} from './MPMessages.jsx'; import {MultiProductChoice} from './MultiProductChoice.jsx';