|
@@ -26,11 +26,20 @@ namespace CommandIDs {
|
|
export
|
|
export
|
|
const zoomOut = 'imageviewer:zoom-out';
|
|
const zoomOut = 'imageviewer:zoom-out';
|
|
|
|
|
|
|
|
+ export
|
|
|
|
+ const flipHorizontal = 'imageviewer:flip-horizontal';
|
|
|
|
+
|
|
|
|
+ export
|
|
|
|
+ const flipVertical = 'imageviewer:flip-vertical';
|
|
|
|
+
|
|
export
|
|
export
|
|
const rotateClockwise = 'imageviewer:rotate-clockwise';
|
|
const rotateClockwise = 'imageviewer:rotate-clockwise';
|
|
|
|
|
|
export
|
|
export
|
|
const rotateCounterclockwise = 'imageviewer:rotate-counterclockwise';
|
|
const rotateCounterclockwise = 'imageviewer:rotate-counterclockwise';
|
|
|
|
+
|
|
|
|
+ export
|
|
|
|
+ const invertColors = 'imageviewer:invert-colors';
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -104,7 +113,7 @@ function activate(app: JupyterLab, palette: ICommandPalette, restorer: ILayoutRe
|
|
|
|
|
|
const category = 'Image Viewer';
|
|
const category = 'Image Viewer';
|
|
|
|
|
|
- [CommandIDs.zoomIn, CommandIDs.zoomOut, CommandIDs.resetImage, CommandIDs.rotateClockwise, CommandIDs.rotateCounterclockwise]
|
|
|
|
|
|
+ [CommandIDs.zoomIn, CommandIDs.zoomOut, CommandIDs.resetImage, CommandIDs.rotateClockwise, CommandIDs.rotateCounterclockwise, CommandIDs.flipHorizontal, CommandIDs.flipVertical, CommandIDs.invertColors]
|
|
.forEach(command => { palette.addItem({ command, category }); });
|
|
.forEach(command => { palette.addItem({ command, category }); });
|
|
|
|
|
|
return tracker;
|
|
return tracker;
|
|
@@ -156,6 +165,24 @@ function addCommands(app: JupyterLab, tracker: IImageTracker) {
|
|
isEnabled
|
|
isEnabled
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ commands.addCommand('imageviewer:flip-horizontal', {
|
|
|
|
+ execute: flipHorizontal,
|
|
|
|
+ label: 'Flip image horizontally',
|
|
|
|
+ isEnabled
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ commands.addCommand('imageviewer:flip-vertical', {
|
|
|
|
+ execute: flipVertical,
|
|
|
|
+ label: 'Flip image vertically',
|
|
|
|
+ isEnabled
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ commands.addCommand('imageviewer:invert-colors', {
|
|
|
|
+ execute: invertColors,
|
|
|
|
+ label: 'Invert Colors',
|
|
|
|
+ isEnabled
|
|
|
|
+ });
|
|
|
|
+
|
|
function zoomIn(): void {
|
|
function zoomIn(): void {
|
|
const widget = tracker.currentWidget;
|
|
const widget = tracker.currentWidget;
|
|
|
|
|
|
@@ -178,6 +205,9 @@ function addCommands(app: JupyterLab, tracker: IImageTracker) {
|
|
if (widget) {
|
|
if (widget) {
|
|
widget.scale = 1;
|
|
widget.scale = 1;
|
|
widget.rotation = 0;
|
|
widget.rotation = 0;
|
|
|
|
+ widget.horizontalflip = 1;
|
|
|
|
+ widget.verticalflip = 1;
|
|
|
|
+ widget.colorinversion = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -196,5 +226,30 @@ function addCommands(app: JupyterLab, tracker: IImageTracker) {
|
|
widget.rotation -= 90;
|
|
widget.rotation -= 90;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ function flipHorizontal(): void {
|
|
|
|
+ const widget = tracker.currentWidget;
|
|
|
|
+
|
|
|
|
+ if (widget) {
|
|
|
|
+ widget.horizontalflip *= -1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function flipVertical(): void {
|
|
|
|
+ const widget = tracker.currentWidget;
|
|
|
|
+
|
|
|
|
+ if (widget) {
|
|
|
|
+ widget.verticalflip *= -1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function invertColors(): void {
|
|
|
|
+ const widget = tracker.currentWidget;
|
|
|
|
+
|
|
|
|
+ if (widget) {
|
|
|
|
+ widget.colorinversion += 1;
|
|
|
|
+ widget.colorinversion %= 2;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|