Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

concept of new scoring output configuration #1932

Merged
merged 10 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
689 changes: 633 additions & 56 deletions src/ThreeEditor/Simulation/Scoring/ScoringOutputTypes.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/ThreeEditor/Simulation/Scoring/ScoringQtyModifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class DifferentialModifier {
type: 'differential' = 'differential';
uuid: string;
constructor(
diffType: DETECTOR_MODIFIERS = 'ANGLE',
diffType: DETECTOR_MODIFIERS = DETECTOR_MODIFIERS.ANGLE,
lowerLimit: number = 0,
binsNumber: number = 500,
upperLimit: number = 10,
Expand Down
21 changes: 16 additions & 5 deletions src/ThreeEditor/Simulation/Scoring/ScoringQuantity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ export class ScoringQuantity extends SimulationZone {

set keyword(keyword: Scoring.DETECTOR_KEYWORD) {
this._keyword = keyword;
let currentSimulator = this.editor.contextManager.currentSimulator;

if (!Scoring.canChangeMaterialMedium(keyword)) this.hasMaterial = false;
if (!Scoring.canChangeMaterialMedium(currentSimulator, 'DETECTOR', keyword)) //TODO scoringType from enum instead of 'DETECTOR'
this.hasMaterial = false;
}

hasFilter: boolean;
Expand All @@ -50,7 +52,7 @@ export class ScoringQuantity extends SimulationZone {
}

get primaries(): number {
return this._hasPrimaries ? this._primaries ?? 0 : 0;
return this._hasPrimaries ? (this._primaries ?? 0) : 0;
}

set primaries(value: number) {
Expand Down Expand Up @@ -88,7 +90,10 @@ export class ScoringQuantity extends SimulationZone {
}

get medium(): Scoring.MEDIUM | null {
if (Scoring.canChangeNKMedium(this.keyword)) return this._medium;
let currentSimulator = this.editor.contextManager.currentSimulator;

if (Scoring.canChangeNKMedium(currentSimulator, 'DETECTOR', this.keyword)) // TODO 'DETECTOR'
return this._medium;

return null;
}
Expand All @@ -107,7 +112,10 @@ export class ScoringQuantity extends SimulationZone {
}

get hasMaterial(): boolean {
if (Scoring.canChangeMaterialMedium(this.keyword)) return this._hasMaterial;
let currentSimulator = this.editor.contextManager.currentSimulator;

if (Scoring.canChangeMaterialMedium(currentSimulator, 'DETECTOR', this.keyword))
return this._hasMaterial; // TODO scoringType from #1906

return false;
}
Expand Down Expand Up @@ -135,7 +143,10 @@ export class ScoringQuantity extends SimulationZone {
return this._modifiers[uuid];
}

constructor(editor: YaptideEditor, keyword: Scoring.DETECTOR_KEYWORD = 'Dose') {
constructor(
editor: YaptideEditor,
keyword: Scoring.DETECTOR_KEYWORD = Scoring.DETECTOR_KEYWORD.Dose
) {
super(editor, 'Quantity', 'Quantity');
this._modifiers = {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import {
canChangeMaterialMedium,
canChangeNKMedium,
canChangePrimaryMultiplier,
DETECTOR_KEYWORD_OPTIONS,
FLUKA_DETECTOR_KEYWORD_OPTIONS,
MEDIUM_KEYWORD_OPTIONS
} from '../../../../Simulation/Scoring/ScoringOutputTypes';
getQuantityTypeOptions,
MEDIUM_KEYWORD_OPTIONS} from '../../../../Simulation/Scoring/ScoringOutputTypes';
import { isScoringQuantity, ScoringQuantity } from '../../../../Simulation/Scoring/ScoringQuantity';
import { ObjectSelectPropertyField } from '../fields/ObjectSelectPropertyField';
import {
Expand All @@ -35,20 +33,18 @@ export function QuantityConfiguration(props: { editor: YaptideEditor; object: Ob
editor.execute(new SetQuantityValueCommand(editor, watchedObject.object, key, value));
};

let currentSimulator = editor.contextManager.currentSimulator;

const fields = (
<>
<ObjectSelectPropertyField
label='Quantity type'
value={watchedObject.keyword}
options={
editor.contextManager.currentSimulator === SimulatorType.SHIELDHIT
? DETECTOR_KEYWORD_OPTIONS
: FLUKA_DETECTOR_KEYWORD_OPTIONS
}
options={getQuantityTypeOptions(currentSimulator, 'DETECTOR')}
onChange={v => setQuantityValue('keyword', v.uuid)}
/>

{canChangeNKMedium(watchedObject.keyword) &&
{canChangeNKMedium(currentSimulator, 'DETECTOR', watchedObject.keyword) &&
editor.contextManager.currentSimulator === SimulatorType.SHIELDHIT && (
<>
<ObjectSelectPropertyField
Expand All @@ -60,7 +56,7 @@ export function QuantityConfiguration(props: { editor: YaptideEditor; object: Ob
</>
)}

{canChangeMaterialMedium(watchedObject.keyword) &&
{canChangeMaterialMedium(currentSimulator, 'DETECTOR', watchedObject.keyword) &&
editor.contextManager.currentSimulator === SimulatorType.SHIELDHIT && (
<BooleanPropertyField
label='Override material'
Expand All @@ -69,7 +65,7 @@ export function QuantityConfiguration(props: { editor: YaptideEditor; object: Ob
/>
)}

{canChangePrimaryMultiplier(watchedObject.keyword) &&
{canChangePrimaryMultiplier(currentSimulator, 'DETECTOR', watchedObject.keyword) &&
editor.contextManager.currentSimulator === SimulatorType.SHIELDHIT && (
<ConditionalNumberPropertyField
label='Primaries'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { SetQuantityValueCommand } from '../../../../js/commands/SetQuantityValu
import { YaptideEditor } from '../../../../js/YaptideEditor';
import {
DETECTOR_MODIFIERS,
DETECTOR_MODIFIERS_OPTIONS
getQuantityModifiersOptions
} from '../../../../Simulation/Scoring/ScoringOutputTypes';
import { DifferentialModifier } from '../../../../Simulation/Scoring/ScoringQtyModifiers';
import { isScoringQuantity, ScoringQuantity } from '../../../../Simulation/Scoring/ScoringQuantity';
Expand All @@ -29,6 +29,9 @@ export function QuantityDifferentialScoring(props: { editor: YaptideEditor; obje

const visibleFlag = isScoringQuantity(watchedObject);

let keyword = watchedObject.keyword;
let currentSimulator = editor.contextManager.currentSimulator;

return (
<PropertiesCategory
category='Differential Scoring'
Expand Down Expand Up @@ -71,7 +74,16 @@ export function QuantityDifferentialScoring(props: { editor: YaptideEditor; obje
upperLimit={watchedObject.selectedModifier.upperLimit}
binsNumber={watchedObject.selectedModifier.binsNumber}
logCheckbox={watchedObject.selectedModifier.isLog}
options={DETECTOR_MODIFIERS_OPTIONS}
options={Array.from(
getQuantityModifiersOptions(currentSimulator, 'DETECTOR', keyword)
).reduce(
(acc, key) => {
acc[key] = key;

return acc;
},
{} as Record<DETECTOR_MODIFIERS, DETECTOR_MODIFIERS>
)}
onChange={v => {
editor.execute(
new AddDifferentialModifierCommand(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
import { hideUIElement, showUIElement } from '../../../../../util/Ui/Uis';
import { YaptideEditor } from '../../../../js/YaptideEditor';
import { isFloatRule, isIDRule, isIntRule } from '../../../../Simulation/Scoring/FilterRule';
import { DETECTOR_MODIFIERS_OPTIONS } from '../../../../Simulation/Scoring/ScoringOutputTypes';
import { DETECTOR_MODIFIERS_OPTIONS_TYPE } from '../../../../Simulation/Scoring/ScoringOutputTypes';
import { DifferentialModifier } from '../../../../Simulation/Scoring/ScoringQtyModifiers';
import { ObjectSelectProperty, ObjectSelectProps } from './ObjectSelectPropertyField';

Expand Down Expand Up @@ -441,7 +441,7 @@ export function DifferentialConfiguration(props: {
upperLimit: number;
binsNumber: number;
logCheckbox: boolean;
options: typeof DETECTOR_MODIFIERS_OPTIONS;
options: typeof DETECTOR_MODIFIERS_OPTIONS_TYPE;
onChange: (value: {
keywordSelect: string;
lowerLimit: number;
Expand Down
2 changes: 1 addition & 1 deletion src/ThreeEditor/js/sidebar/object/Object.Differentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class ObjectDifferentials extends ObjectAbstract {
] = createDifferentialConfigurationRow({
update: this.update.bind(this),
delete: this.removeModifier.bind(this),
options: Scoring.DETECTOR_MODIFIERS_OPTIONS
options: Scoring.DETECTOR_MODIFIERS_OPTIONS_TYPE
});
this.panel.add(this.addRow, this.outliner, new UIBreak(), this.modifierRow);
editor.signals.scoringQuantityChanged.add(() =>
Expand Down
19 changes: 10 additions & 9 deletions src/ThreeEditor/js/sidebar/object/Object.Quantity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class ObjectQuantity extends ObjectAbstract {
[this.keywordRow, this.keyword] = createRowSelect({
text: 'Quantity type',
update: this.update.bind(this),
options: Scoring.DETECTOR_KEYWORD_OPTIONS
options: Scoring.SHIELDHIT_DETECTOR_KEYWORD_OPTIONS
});

[this.mediumRow, this.medium] = createRowSelect({
Expand Down Expand Up @@ -63,9 +63,9 @@ export class ObjectQuantity extends ObjectAbstract {

const { filter, hasFilter, rescale, hasRescale, medium, keyword } = object;
this.keyword.setValue(keyword);

if (Scoring.canChangeNKMedium(keyword)) showUIElement(this.mediumRow);
else hideUIElement(this.mediumRow);
// File unused #1893
// if (Scoring.canChangeNKMedium(keyword)) showUIElement(this.mediumRow);
// else hideUIElement(this.mediumRow);
this.medium.setValue(medium ?? Scoring.MEDIUM_KEYWORD_OPTIONS.WATER);

const options = this.editor.scoringManager.getFilterOptions();
Expand Down Expand Up @@ -103,11 +103,12 @@ export class ObjectQuantity extends ObjectAbstract {

if (keyword !== newKeyword)
commands.push(new SetQuantityValueCommand(editor, object, 'keyword', newKeyword));

if (Scoring.canChangeNKMedium(newKeyword)) {
if (medium !== newMedium)
commands.push(new SetQuantityValueCommand(editor, object, 'medium', newMedium));
} else hideUIElement(this.mediumRow);
// File unused #1893
// if (Scoring.canChangeNKMedium(newKeyword)) {
// if (medium !== newMedium)
// commands.push(new SetQuantityValueCommand(editor, object, 'medium', newMedium));
// }
else hideUIElement(this.mediumRow);

if (newHasRescale !== hasRescale)
commands.push(new SetQuantityValueCommand(editor, object, 'hasRescale', newHasRescale));
Expand Down
Loading