diff --git a/baby-gru/cloud/src/MoorhenWrapper.tsx b/baby-gru/cloud/src/MoorhenWrapper.tsx index e42489a4..6219321f 100644 --- a/baby-gru/cloud/src/MoorhenWrapper.tsx +++ b/baby-gru/cloud/src/MoorhenWrapper.tsx @@ -39,7 +39,7 @@ type PdbInputFileType = { type MapInputFileType = { type: 'mtz'; uniqueId?: string; - args: [string, string, moorhen.selectedMtzColumns]; + args: [string, string, moorhen.selectedMtzColumns, {r: number, g: number, b: number}?]; } type LegendInputFileType = { @@ -221,20 +221,27 @@ export default class MoorhenWrapper { } } - async loadMtzData(uniqueId: string, inputFile: string, mapName: string, selectedColumns: moorhen.selectedMtzColumns): Promise { + async loadMtzData(uniqueId: string, inputFile: string, mapName: string, selectedColumns: moorhen.selectedMtzColumns, mapColour?: {r: number, g: number, b: number}): Promise { const newMap = new MoorhenMap(this.controls.commandCentre) newMap.litLines = this.context.defaultMapLitLines newMap.uniqueId = uniqueId + + if (mapColour) { + newMap.rgba = { r: mapColour.r, g: mapColour.g, b: mapColour.b, a: 1.0 } + } + return new Promise(async (resolve, reject) => { try { await newMap.loadToCootFromMtzURL(inputFile, mapName, selectedColumns) this.controls.changeMaps({ action: 'Add', item: newMap }) this.controls.setActiveMap(newMap) return resolve(newMap) + } catch (err) { console.log(`Cannot fetch mtz from ${inputFile}`) return reject(err) } + }) } diff --git a/baby-gru/src/types/moorhen.d.ts b/baby-gru/src/types/moorhen.d.ts index 4aed9483..6482874a 100644 --- a/baby-gru/src/types/moorhen.d.ts +++ b/baby-gru/src/types/moorhen.d.ts @@ -258,7 +258,7 @@ export namespace moorhen { makeCootLive(glRef: React.RefObject): void; setColour(r: number, g: number, b: number, glRef: React.RefObject, redraw?: boolean): Promise; fetchMapRmsd(): Promise; - replaceMapWithMtzFile(glRef: React.RefObject, fileUrl: RequestInfo | URL, name: string, selectedColumns: selectedMtzColumns): Promise; + replaceMapWithMtzFile(glRef: React.RefObject, fileUrl: RequestInfo | URL, name: string, selectedColumns: selectedMtzColumns, mapColour?: {r: number, g: number, b: number}): Promise; associateToReflectionData (selectedColumns: selectedMtzColumns, reflectionData: Uint8Array | ArrayBuffer): Promise; delete(glRef: React.RefObject): Promise doCootContour(glRef: React.MutableRefObject, x: number, y: number, z: number, radius: number, contourLevel: number): Promise; diff --git a/baby-gru/src/utils/MoorhenMap.ts b/baby-gru/src/utils/MoorhenMap.ts index f11c0233..037c2511 100644 --- a/baby-gru/src/utils/MoorhenMap.ts +++ b/baby-gru/src/utils/MoorhenMap.ts @@ -46,7 +46,7 @@ export class MoorhenMap implements moorhen.Map { this.associatedReflectionFileName = null this.uniqueId = guid() this.mapRmsd = null - this.rgba = { r: 0.30000001192092896, g: 0.30000001192092896, b: 0.699999988079071, a: 1.0 } + this.rgba = { r: 0.30000001192092896, g: 0.30000001192092896, b: 0.699999988079071, a: 1.0 } } async fetchMapRmsd(): Promise { @@ -79,7 +79,7 @@ export class MoorhenMap implements moorhen.Map { await Promise.all(promises) } - async replaceMapWithMtzFile(glRef: React.RefObject, fileUrl: RequestInfo | URL, name: string, selectedColumns: moorhen.selectedMtzColumns): Promise { + async replaceMapWithMtzFile(glRef: React.RefObject, fileUrl: RequestInfo | URL, name: string, selectedColumns: moorhen.selectedMtzColumns, mapColour?: {r: number, g: number, b: number}): Promise { let mtzData: Uint8Array let fetchResponse: Response