Skip to content

Commit

Permalink
Better tool availibility filtering according to data. Fixes #230.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Mar 3, 2021
1 parent 47586a2 commit a4c3228
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/app/dwv/dwv.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
});
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit a4c3228

Please sign in to comment.