Skip to content

Commit d28d98c

Browse files
Add a toggle button to enable to add a draw vector layer.
Add a isDrawVectorLayerEnabled property to the JupyterGISModel.
1 parent 9e9cc28 commit d28d98c

File tree

8 files changed

+64
-2
lines changed

8 files changed

+64
-2
lines changed

packages/base/src/commands.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
} from './processing';
3434
import { fromLonLat } from 'ol/proj';
3535
import { Coordinate } from 'ol/coordinate';
36-
import { targetWithCenterIcon } from './icons';
36+
import { pencilSolidIcon, targetWithCenterIcon } from './icons';
3737

3838
interface ICreateEntry {
3939
tracker: JupyterGISTracker;
@@ -878,6 +878,32 @@ export function addCommands(
878878
icon: targetWithCenterIcon
879879
});
880880

881+
commands.addCommand(CommandIDs.newDrawVectorLayer, {
882+
label: trans.__('Create New Draw Vector Layer'),
883+
isToggled: () => {
884+
if (tracker.currentWidget instanceof JupyterGISDocumentWidget) {
885+
const model = tracker.currentWidget?.content.currentViewModel
886+
.jGISModel as IJupyterGISModel;
887+
return model.isDrawVectorLayerEnabled;
888+
} else {
889+
return false;
890+
}
891+
},
892+
execute: async () => {
893+
if (tracker.currentWidget instanceof JupyterGISDocumentWidget) {
894+
const model = tracker.currentWidget?.content.currentViewModel
895+
.jGISModel as IJupyterGISModel;
896+
if (model.isDrawVectorLayerEnabled === true) {
897+
model.isDrawVectorLayerEnabled = false;
898+
} else {
899+
model.isDrawVectorLayerEnabled = true;
900+
}
901+
commands.notifyCommandChanged(CommandIDs.newDrawVectorLayer);
902+
}
903+
},
904+
icon: pencilSolidIcon
905+
});
906+
881907
loadKeybindings(commands, keybindings);
882908
}
883909

packages/base/src/constants.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ export namespace CommandIDs {
4040
export const buffer = 'jupytergis:buffer';
4141
export const dissolve = 'jupytergis:dissolve';
4242

43+
// Layers only commands
44+
export const newRasterLayer = 'jupytergis:newRasterLayer';
45+
export const newVectorLayer = 'jupytergis:newVectorLayer';
46+
export const newHillshadeLayer = 'jupytergis:newHillshadeLayer';
47+
export const newImageLayer = 'jupytergis:newImageLayer';
48+
export const newVideoLayer = 'jupytergis:newVideoLayer';
49+
export const newShapefileLayer = 'jupytergis:newShapefileLayer';
50+
export const newWebGlTileLayer = 'jupytergis:newWebGlTileLayer';
51+
export const newHeatmapLayer = 'jupytergis:newHeatmapLayer';
52+
export const newDrawVectorLayer = 'jupytergis:newDrawVectorLayer';
53+
4354
// Layer and group actions
4455
export const renameLayer = 'jupytergis:renameLayer';
4556
export const removeLayer = 'jupytergis:removeLayer';

packages/base/src/icons.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import terminalToolbarSvgStr from '../style/icons/terminal_toolbar.svg';
2323
import geolocationSvgStr from '../style/icons/geolocation.svg';
2424
import targetWithoutCenterSvgStr from '../style/icons/target_without_center.svg';
2525
import targetWithCenterSvgStr from '../style/icons/target_with_center.svg';
26+
import pencilSolidSvgStr from '../style/icons/pencil_solid.svg';
2627

2728
export const logoIcon = new LabIcon({
2829
name: 'jupytergis::logo',
@@ -108,3 +109,8 @@ export const targetWithCenterIcon = new LabIcon({
108109
name: 'jupytergis::targetWithoutCenter',
109110
svgstr: targetWithoutCenterSvgStr
110111
});
112+
113+
export const pencilSolidIcon = new LabIcon({
114+
name: 'jupytergis::pencilSolid',
115+
svgstr: pencilSolidSvgStr
116+
});

packages/base/src/mainview/mainView.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ interface IStates {
106106
loadingErrors: Array<{ id: string; error: any; index: number }>;
107107
displayTemporalController: boolean;
108108
filterStates: IDict<IJGISFilterItem | undefined>;
109+
drawVectorLayerEnabled: boolean;
109110
}
110111

111112
export class MainView extends React.Component<IProps, IStates> {
@@ -168,7 +169,8 @@ export class MainView extends React.Component<IProps, IStates> {
168169
scale: 0,
169170
loadingErrors: [],
170171
displayTemporalController: false,
171-
filterStates: {}
172+
filterStates: {},
173+
drawVectorLayerEnabled: false
172174
};
173175

174176
this._sources = [];
Lines changed: 9 additions & 0 deletions
Loading

packages/schema/src/interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ export interface IJupyterGISModel extends DocumentRegistry.IModel {
232232
triggerLayerUpdate(layerId: string, layer: IJGISLayer): void;
233233

234234
disposed: ISignal<any, void>;
235+
isDrawVectorLayerEnabled: boolean;
235236
}
236237

237238
export interface IUserData {

packages/schema/src/model.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export class JupyterGISModel implements IJupyterGISModel {
5454
this
5555
);
5656
this.annotationModel = annotationModel;
57+
this.isDrawVectorLayerEnabled = false;
5758
this.settingRegistry = settingRegistry;
5859
}
5960

@@ -783,6 +784,8 @@ export class JupyterGISModel implements IJupyterGISModel {
783784

784785
private _geolocation: JgisCoordinates;
785786
private _geolocationChanged = new Signal<this, JgisCoordinates>(this);
787+
788+
public isDrawVectorLayerEnabled: boolean;
786789
}
787790

788791
export namespace JupyterGISModel {

test-results/.last-run.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"status": "failed",
3+
"failedTests": []
4+
}

0 commit comments

Comments
 (0)