From a4c32288849731d8b252a2bfff187419c2d6f4b9 Mon Sep 17 00:00:00 2001 From: ivmartel Date: Thu, 4 Mar 2021 00:04:09 +0100 Subject: [PATCH] Better tool availibility filtering according to data. Fixes #230. --- src/app/dwv/dwv.component.ts | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/app/dwv/dwv.component.ts b/src/app/dwv/dwv.component.ts index 753399ab..be96a3d2 100644 --- a/src/app/dwv/dwv.component.ts +++ b/src/app/dwv/dwv.component.ts @@ -35,6 +35,7 @@ export class DwvComponent implements OnInit { events: ['drawcreate', 'drawchange', 'drawmove', 'drawdelete'] } }; + public toolNames: string[]; public selectedTool = 'Select Tool'; public loadProgress = 0; public dataLoaded = false; @@ -81,13 +82,16 @@ export class DwvComponent implements OnInit { this.dwvApp.addEventListener('load', (/*event*/) => { // set dicom tags this.metaData = dwv.utils.objectToArray(this.dwvApp.getMetaData()); - // set the selected tool - let selectedTool = 'Scroll'; - if (this.dwvApp.isMonoSliceData() && - this.dwvApp.getImage().getNumberOfFrames() === 1) { - selectedTool = 'ZoomAndPan'; + // available tools + this.toolNames = []; + for (const key in this.tools) { + if ((key === 'Scroll' && this.dwvApp.canScroll()) || + (key === 'WindowLevel' && this.dwvApp.canWindowLevel()) || + (key !== 'Scroll' && key !== 'WindowLevel')) { + this.toolNames.push(key); + } } - this.onChangeTool(selectedTool); + this.onChangeTool(this.toolNames[0]); // set data loaded flag this.dataLoaded = true; }); @@ -131,13 +135,6 @@ export class DwvComponent implements OnInit { dwv.utils.loadFromUri(window.location.href, this.dwvApp); } - /** - * Get the tool names as a string array. - */ - get toolNames(): string[] { - return Object.keys(this.tools); - } - /** * Handle a change tool event. * @param tool The new tool name.