Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Commit

Permalink
enable map colour settings in cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
FilomenoSanchez committed Jun 30, 2023
1 parent 9dbc7b3 commit 0955266
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
11 changes: 9 additions & 2 deletions baby-gru/cloud/src/MoorhenWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -221,20 +221,27 @@ export default class MoorhenWrapper {
}
}

async loadMtzData(uniqueId: string, inputFile: string, mapName: string, selectedColumns: moorhen.selectedMtzColumns): Promise<moorhen.Map> {
async loadMtzData(uniqueId: string, inputFile: string, mapName: string, selectedColumns: moorhen.selectedMtzColumns, mapColour?: {r: number, g: number, b: number}): Promise<moorhen.Map> {
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)
}

})
}

Expand Down
2 changes: 1 addition & 1 deletion baby-gru/src/types/moorhen.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export namespace moorhen {
makeCootLive(glRef: React.RefObject<webGL.MGWebGL>): void;
setColour(r: number, g: number, b: number, glRef: React.RefObject<webGL.MGWebGL>, redraw?: boolean): Promise<void>;
fetchMapRmsd(): Promise<number>;
replaceMapWithMtzFile(glRef: React.RefObject<webGL.MGWebGL>, fileUrl: RequestInfo | URL, name: string, selectedColumns: selectedMtzColumns): Promise<void>;
replaceMapWithMtzFile(glRef: React.RefObject<webGL.MGWebGL>, fileUrl: RequestInfo | URL, name: string, selectedColumns: selectedMtzColumns, mapColour?: {r: number, g: number, b: number}): Promise<void>;
associateToReflectionData (selectedColumns: selectedMtzColumns, reflectionData: Uint8Array | ArrayBuffer): Promise<WorkerResponse>;
delete(glRef: React.RefObject<webGL.MGWebGL>): Promise<void>
doCootContour(glRef: React.MutableRefObject<webGL.MGWebGL>, x: number, y: number, z: number, radius: number, contourLevel: number): Promise<void>;
Expand Down
4 changes: 2 additions & 2 deletions baby-gru/src/utils/MoorhenMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number> {
Expand Down Expand Up @@ -79,7 +79,7 @@ export class MoorhenMap implements moorhen.Map {
await Promise.all(promises)
}

async replaceMapWithMtzFile(glRef: React.RefObject<webGL.MGWebGL>, fileUrl: RequestInfo | URL, name: string, selectedColumns: moorhen.selectedMtzColumns): Promise<void> {
async replaceMapWithMtzFile(glRef: React.RefObject<webGL.MGWebGL>, fileUrl: RequestInfo | URL, name: string, selectedColumns: moorhen.selectedMtzColumns, mapColour?: {r: number, g: number, b: number}): Promise<void> {
let mtzData: Uint8Array
let fetchResponse: Response

Expand Down

0 comments on commit 0955266

Please sign in to comment.