From 8a2208ff2b27990172d332babe6b2924e135fd88 Mon Sep 17 00:00:00 2001 From: Jon Carifio Date: Fri, 30 Jun 2023 12:28:28 +0000 Subject: [PATCH 1/2] research-app: Add logic to change strings to Colors for handling some engine settings. --- research-app/src/App.vue | 7 ++++-- research-app/src/settings.ts | 48 +++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/research-app/src/App.vue b/research-app/src/App.vue index 1339989b..87c048af 100644 --- a/research-app/src/App.vue +++ b/research-app/src/App.vue @@ -426,6 +426,8 @@ import { } from "@wwtelescope/research-app-messages"; import { + convertEngineSetting, + isResearchAppEngineSetting, convertPywwtSpreadSheetLayerSetting, convertSpreadSheetLayerSetting, } from "./settings"; @@ -1970,9 +1972,10 @@ const App = defineComponent({ const setting: [string, any] = [msg.setting, msg.value]; - if (!isEngineSetting(setting)) return false; + if (!isResearchAppEngineSetting(setting)) return false; + const convertedSetting = convertEngineSetting(setting); - this.applySetting(setting); + this.applySetting(convertedSetting); return true; }, diff --git a/research-app/src/settings.ts b/research-app/src/settings.ts index 83fb4d83..681b511a 100644 --- a/research-app/src/settings.ts +++ b/research-app/src/settings.ts @@ -7,7 +7,9 @@ import { AltTypes, AltUnits, + BaseEngineSetting, CoordinatesType, + isBaseEngineSetting, MarkerScales, PlotTypes, PointScaleTypes, @@ -16,6 +18,7 @@ import { import { Color, + EngineSetting, SpreadSheetLayer, SpreadSheetLayerSetting, } from "@wwtelescope/engine"; @@ -24,6 +27,31 @@ import { classicPywwt, } from "@wwtelescope/research-app-messages"; + +export type ResearchAppEngineSetting = BaseEngineSetting | + ["altAzGridColor", string] | + ["eclipticColor", string] | + ["eclipticGridColor", string] | + ["equatorialGridColor", string] | + ["galacticGridColor", string] | + ["precessionChartColor", string]; + +const researchAppEngineSettingTypeInfo = { + "altAzGridColor/string": true, + "eclipticColor/string": true, + "eclipticGridColor/string": true, + "equatorialGridColor/string": true, + "galacticGridColor/string": true, + "precessionChartColor/string": true, +}; + +export function isResearchAppEngineSetting(obj: [string, any]): obj is ResearchAppEngineSetting { // eslint-disable-line @typescript-eslint/no-explicit-any + if (isBaseEngineSetting(obj)) return true; + + const key = obj[0] + "/" + typeof obj[1]; + return (key in researchAppEngineSettingTypeInfo); +} + function colValToIndex(layer: SpreadSheetLayer, colval: number | string): number { if (typeof colval === "number") return colval; @@ -136,4 +164,22 @@ export function convertSpreadSheetLayerSetting(setting: SpreadSheetLayerSetting) } return setting; -} \ No newline at end of file +} + +export function convertEngineSetting(setting: ResearchAppEngineSetting): EngineSetting { + if (setting[0] == "altAzGridColor") { + return [setting[0], Color.load(setting[1])]; + } else if (setting[0] == "eclipticColor") { + return [setting[0], Color.load(setting[1])]; + } else if (setting[0] == "eclipticGridColor") { + return [setting[0], Color.load(setting[1])]; + } else if (setting[0] == "equatorialGridColor") { + return [setting[0], Color.load(setting[1])]; + } else if (setting[0] == "galacticGridColor") { + return [setting[0], Color.load(setting[1])]; + } else if (setting[0] == "precessionChartColor") { + return [setting[0], Color.load(setting[1])]; + } + + return setting; +} From d653479e5b8dbaa4b311295404546babb103e372 Mon Sep 17 00:00:00 2001 From: Jon Carifio Date: Fri, 30 Jun 2023 14:26:51 +0000 Subject: [PATCH 2/2] Set annotation batch as dirty after changing annotation opacity. --- engine/wwtlib/Annotation.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engine/wwtlib/Annotation.cs b/engine/wwtlib/Annotation.cs index e22f2ee0..ae2f3a2a 100644 --- a/engine/wwtlib/Annotation.cs +++ b/engine/wwtlib/Annotation.cs @@ -97,7 +97,11 @@ public static double Separation(double Alpha1, double Delta1, double Alpha2, dou public double Opacity { get { return opacity; } - set { opacity = value; } + set + { + Annotation.BatchDirty = true; + opacity = value; + } } string id;