Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/base/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,14 @@ export function addCommands(
'WebGlLayer',
'VectorTileLayer',
].includes(selectedLayer.type);
const isIdentifying = current.model.isIdentifying;

if (isIdentifying && !canIdentify) {
current.model.isIdentifying = false;
if (current.model.currentMode === 'identifying' && !canIdentify) {
current.model.currentMode = 'panning';
current.node.classList.remove('jGIS-identify-tool');
return false;
}

return isIdentifying;
return current.model.currentMode === 'identifying';
},
isEnabled: () => {
if (tracker.currentWidget?.model.jgisSettings.identifyDisabled) {
Expand Down Expand Up @@ -198,7 +197,7 @@ export function addCommands(
if (luminoEvent) {
const keysPressed = luminoEvent.keys as string[] | undefined;
if (keysPressed?.includes('Escape')) {
current.model.isIdentifying = false;
current.model.currentMode = 'panning';
current.node.classList.remove('jGIS-identify-tool');
commands.notifyCommandChanged(CommandIDs.identify);
return;
Expand All @@ -207,6 +206,7 @@ export function addCommands(

current.node.classList.toggle('jGIS-identify-tool');
current.model.toggleIdentify();

commands.notifyCommandChanged(CommandIDs.identify);
},
...icons.get(CommandIDs.identify),
Expand Down
7 changes: 3 additions & 4 deletions packages/base/src/mainview/mainView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ export class MainView extends React.Component<IProps, IStates> {

// Watch isIdentifying and clear the highlight when Identify Tool is turned off
this._model.sharedModel.awareness.on('change', () => {
const isIdentifying = this._model.isIdentifying;
if (!isIdentifying && this._highlightLayer) {
if (this._model.currentMode !== 'identifying' && this._highlightLayer) {
this._highlightLayer.getSource()?.clear();
}
});
Expand Down Expand Up @@ -519,7 +518,7 @@ export class MainView extends React.Component<IProps, IStates> {
return layer === this.getLayer(selectedLayerId);
},
condition: (event: MapBrowserEvent<any>) => {
return singleClick(event) && this._model.isIdentifying;
return singleClick(event) && this._model.currentMode === 'identifying';
},
style: styleFunction,
});
Expand Down Expand Up @@ -2086,7 +2085,7 @@ export class MainView extends React.Component<IProps, IStates> {
});

private _identifyFeature(e: MapBrowserEvent<any>) {
if (!this._model.isIdentifying) {
if (this._model.currentMode !== 'identifying') {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ export const IdentifyPanelComponent: React.FC<IIdentifyComponentProps> = ({
return;
}

if (model.isIdentifying && featuresRef.current !== identifiedFeatures) {
if (
model.currentMode === 'identifying' &&
featuresRef.current !== identifiedFeatures
) {
setFeatures(identifiedFeatures);
}
};
Expand Down
52 changes: 36 additions & 16 deletions packages/base/src/panelview/rightpanel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
IAnnotationModel,
IJGISFormSchemaRegistry,
IJupyterGISClientState,
IJupyterGISModel,
} from '@jupytergis/schema';
import * as React from 'react';
Expand All @@ -23,15 +24,50 @@ interface IRightPanelProps {

export const RightPanel: React.FC<IRightPanelProps> = props => {
const [settings, setSettings] = React.useState(props.model.jgisSettings);
const tabInfo = [
!settings.objectPropertiesDisabled
? { name: 'objectProperties', title: 'Object Properties' }
: false,
!settings.annotationsDisabled
? { name: 'annotations', title: 'Annotations' }
: false,
!settings.identifyDisabled
? { name: 'identifyPanel', title: 'Identified Features' }
: false,
].filter(Boolean) as { name: string; title: string }[];

const [curTab, setCurTab] = React.useState<string | undefined>(
tabInfo.length > 0 ? tabInfo[0].name : undefined,
);

React.useEffect(() => {
const onSettingsChanged = () => {
setSettings({ ...props.model.jgisSettings });
};
let currentlyIdentifiedFeatures: any = undefined;
const onAwerenessChanged = (
_: IJupyterGISModel,
clients: Map<number, IJupyterGISClientState>,
) => {
const clientId = props.model.getClientId();
const localState = clientId ? clients.get(clientId) : null;

if (
localState &&
localState.identifiedFeatures?.value &&
localState.identifiedFeatures.value !== currentlyIdentifiedFeatures
) {
currentlyIdentifiedFeatures = localState.identifiedFeatures.value;
setCurTab('identifyPanel');
}
};

props.model.settingsChanged.connect(onSettingsChanged);
props.model.clientStateChanged.connect(onAwerenessChanged);

return () => {
props.model.settingsChanged.disconnect(onSettingsChanged);
props.model.clientStateChanged.disconnect(onAwerenessChanged);
};
}, [props.model]);

Expand All @@ -43,22 +79,6 @@ export const RightPanel: React.FC<IRightPanelProps> = props => {
const rightPanelVisible =
!settings.rightPanelDisabled && !allRightTabsDisabled;

const tabInfo = [
!settings.objectPropertiesDisabled
? { name: 'objectProperties', title: 'Object Properties' }
: false,
!settings.annotationsDisabled
? { name: 'annotations', title: 'Annotations' }
: false,
!settings.identifyDisabled
? { name: 'identifyPanel', title: 'Identified Features' }
: false,
].filter(Boolean) as { name: string; title: string }[];

const [curTab, setCurTab] = React.useState<string | undefined>(
tabInfo.length > 0 ? tabInfo[0].name : undefined,
);

const [selectedObjectProperties, setSelectedObjectProperties] =
React.useState(undefined);

Expand Down
4 changes: 3 additions & 1 deletion packages/schema/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ export interface IJupyterGISModel extends DocumentRegistry.IModel {
localState: IJupyterGISClientState | null;
annotationModel?: IAnnotationModel;

// TODO Add more modes: "annotating"
currentMode: 'panning' | 'identifying';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh nice


themeChanged: Signal<
IJupyterGISModel,
IChangedArgs<string, string | null, string>
Expand Down Expand Up @@ -244,7 +247,6 @@ export interface IJupyterGISModel extends DocumentRegistry.IModel {
centerOnPosition(id: string): void;

toggleIdentify(): void;
isIdentifying: boolean;

isTemporalControllerActive: boolean;
toggleTemporalController(): void;
Expand Down
25 changes: 15 additions & 10 deletions packages/schema/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,6 @@ export class JupyterGISModel implements IJupyterGISModel {
return this._zoomToPositionSignal;
}

set isIdentifying(isIdentifying: boolean) {
this._isIdentifying = isIdentifying;
}

get isIdentifying(): boolean {
return this._isIdentifying;
}

set isTemporalControllerActive(isActive: boolean) {
this._isTemporalControllerActive = isActive;
}
Expand Down Expand Up @@ -767,7 +759,19 @@ export class JupyterGISModel implements IJupyterGISModel {
}

toggleIdentify() {
this._isIdentifying = !this._isIdentifying;
if (this._currentMode === 'identifying') {
this._currentMode = 'panning';
} else {
this._currentMode = 'identifying';
}
}
Comment on lines +762 to +767
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we can have something more extensible for future:

setIdentifyMode(enabled: boolean): void {
  this.currentMode = enabled ? 'identifying' : 'panning';
}


toggleIdentify(): void {
  this.setIdentifyMode(this._currentMode !== 'identifying');
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, we can always work on it in the future :)


get currentMode(): 'panning' | 'identifying' {
return this._currentMode;
}

set currentMode(value: 'panning' | 'identifying') {
this._currentMode = value;
}

toggleTemporalController() {
Expand Down Expand Up @@ -865,6 +869,8 @@ export class JupyterGISModel implements IJupyterGISModel {
private _settingsChanged: Signal<JupyterGISModel, string>;
private _jgisSettings: IJupyterGISSettings;

private _currentMode: 'panning' | 'identifying';

private _sharedModel: IJupyterGISDoc;
private _filePath: string;
private _contentsManager?: Contents.IManager;
Expand Down Expand Up @@ -892,7 +898,6 @@ export class JupyterGISModel implements IJupyterGISModel {

private _updateLayerSignal = new Signal<this, string>(this);

private _isIdentifying = false;
private _isTemporalControllerActive = false;

static worker: Worker;
Expand Down
2 changes: 1 addition & 1 deletion python/jupytergis_lab/src/notebookrenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import {
JupyterFrontEnd,
JupyterFrontEndPlugin,
} from '@jupyterlab/application';
import { ISettingRegistry } from '@jupyterlab/settingregistry';
import { showErrorMessage } from '@jupyterlab/apputils';
import { ConsolePanel } from '@jupyterlab/console';
import { PathExt } from '@jupyterlab/coreutils';
import { NotebookPanel } from '@jupyterlab/notebook';
import { Contents } from '@jupyterlab/services';
import { ISettingRegistry } from '@jupyterlab/settingregistry';
import { IStateDB } from '@jupyterlab/statedb';
import { Toolbar } from '@jupyterlab/ui-components';
import { CommandRegistry } from '@lumino/commands';
Expand Down