Skip to content

Commit

Permalink
Select zone as scoring object. (#1906)
Browse files Browse the repository at this point in the history
* toggle base

* select zone

* quantities removeld on change

* change scoring type

* 3 years old typo

* scoringType in ObjectInfo and QuantityConfiguration

* temporary fix select zone bug

* attempt to make modifiers selectale with fluence

* enum scoring type

* names for scoring output types

* no prompt when 0 quantities

* concept of new scoring output configuration

* string to element of detector modfiers description

* SCORING_OPTIONS dict

* remake of scoringOutputTypes

* fixes, cleanup

* Update ScoringQuantity.ts

* Update ScoringQuantity.ts

* getQuantityTypeOptions

* reorganization of ScoringOutputTypes

* Update ScoringOutputTypes.ts

* better names, cleanup, bugs

* no empty list if no modifiers

* button disable

* terrible bug wrong condition

* dose

* aria label
  • Loading branch information
jagodek authored Jan 10, 2025
1 parent bfff693 commit 584696f
Show file tree
Hide file tree
Showing 17 changed files with 671 additions and 388 deletions.
4 changes: 4 additions & 0 deletions src/ThreeEditor/Simulation/Scoring/ScoringManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ export class ScoringManager
}, [])
.filter(Boolean);
}

getOutputByQuantityUuid(uuid: string) {
return this.outputs.find(output => output.quantities.some(q => q.uuid === uuid)) ?? null;
}
/***************************************************************/

constructor(editor: YaptideEditor) {
Expand Down
46 changes: 46 additions & 0 deletions src/ThreeEditor/Simulation/Scoring/ScoringOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ import { YaptideEditor } from '../../js/YaptideEditor';
import { SimulationSceneContainer } from '../Base/SimulationContainer';
import { SimulationElement, SimulationElementJSON } from '../Base/SimulationElement';
import { SimulationElementManager } from '../Base/SimulationManager';
import { SimulationZone } from '../Base/SimulationZone';
import { Detector } from '../Detectors/Detector';
import { ScoringFilter } from './ScoringFilter';
import { SCORING_TYPE_ENUM } from './ScoringOutputTypes';
import { ScoringQuantity, ScoringQuantityJSON } from './ScoringQuantity';

export type ScoringOutputJSON = Omit<
SimulationElementJSON & {
quantities: ScoringQuantityJSON[];
detectorUuid?: string;
zoneUuid?: string;
scoringType?: string;
trace: boolean;
traceFilter?: string;
},
Expand Down Expand Up @@ -62,6 +66,10 @@ export class ScoringOutput

private _detector?: string;

private _zone?: string;

private _scoringType: SCORING_TYPE_ENUM = SCORING_TYPE_ENUM.DETECTOR;

//TODO: Issue#320
private _trace: [boolean, string | null];

Expand Down Expand Up @@ -96,13 +104,39 @@ export class ScoringOutput
return this.editor.detectorManager.getDetectorByUuid(this._detector);
}

get zone(): SimulationZone | null {
if (!this._zone) return null;

return this.editor.zoneManager.getZoneByUuid(this._zone);
}

set detector(detector: Detector | null) {
this._detector = detector?.uuid;
this.geometry =
detector?.geometry.clone().translate(...detector.position.toArray()) ?? null;
this.signals.objectSelected.dispatch(this);
}

set zone(zone: SimulationZone | null) {
this._zone = zone?.uuid;
this.geometry = null;
this.signals.objectSelected.dispatch(this);
}

get scoringType(): SCORING_TYPE_ENUM {
return this._scoringType ?? SCORING_TYPE_ENUM.DETECTOR;
}

set scoringType(scoringType: SCORING_TYPE_ENUM) {
this._scoringType = scoringType;

if (scoringType === SCORING_TYPE_ENUM.DETECTOR) {
this._zone = undefined;
} else if (scoringType === SCORING_TYPE_ENUM.ZONE) {
this._detector = undefined;
}
}

constructor(editor: YaptideEditor) {
super(editor, 'Output', 'Output');
this.children = [];
Expand Down Expand Up @@ -148,11 +182,17 @@ export class ScoringOutput
return this.quantities.find(qty => qty.uuid === uuid) ?? null;
}

removeAllQuantities() {
this.quantityContainer.clear();
}

toJSON(): ScoringOutputJSON {
return {
...super.toJSON(),
quantities: this.quantityContainer.toJSON(),
detectorUuid: this._detector,
zoneUuid: this._zone,
scoringType: this._scoringType,
trace: this._trace[0],
...(this.trace[1] && { traceFilter: this.trace[1] })
};
Expand All @@ -163,9 +203,13 @@ export class ScoringOutput
this.name = json.name;
this._trace = [json.trace, json.traceFilter ?? null];
this.quantityContainer.fromJSON(json.quantities);

this.detector = json.detectorUuid
? this.editor.detectorManager.getDetectorByUuid(json.detectorUuid)
: null;
this.zone = json.zoneUuid ? this.editor.zoneManager.getZoneByUuid(json.zoneUuid) : null;

this._scoringType = (json.scoringType as SCORING_TYPE_ENUM) ?? SCORING_TYPE_ENUM.DETECTOR;

return this;
}
Expand All @@ -183,6 +227,8 @@ export class ScoringOutput
duplicated.quantityContainer = this.quantityContainer.duplicate();
duplicated.add(duplicated.quantityContainer);

duplicated._scoringType = this._scoringType ?? SCORING_TYPE_ENUM.DETECTOR;

return duplicated;
}
}
Expand Down
Loading

0 comments on commit 584696f

Please sign in to comment.