Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D Scatter #107

Merged
merged 2 commits into from
Jul 3, 2023
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
13 changes: 13 additions & 0 deletions gluepyter/glue_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,19 @@ def _viewer_factory(
pass
except Exception as e:
widget = ErrorWidget(e, __file__)
elif (
view_type == "glue_vispy_viewers.scatter.scatter_viewer.VispyScatterViewer"
):
try:
widget = self.app.scatter3d(data=viewer_data)
for key, value in viewer_state.items():
try:
setattr(widget.state, key, value)
except Exception:
pass
except Exception as e:
widget = ErrorWidget(e, __file__)

return widget

def _read_view_state(
Expand Down
2 changes: 2 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export namespace CommandIDs {

export const new2DScatter = 'glue-control:new-2d-scatter-viewer';

export const new3DScatter = 'glue-control:new-3d-scatter-viewer';

export const newTable = 'glue-control:new-table-viewer';

export const openControlPanel = 'glue-control:open-control-panel';
Expand Down
1 change: 1 addition & 0 deletions src/leftPanel/data/datasetsWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class DatasetsWidget extends ReactWidget {
viewerSubmenu.title.iconClass = 'fa fa-caret-right';
viewerSubmenu.addItem({ command: CommandIDs.new1DHistogram });
viewerSubmenu.addItem({ command: CommandIDs.new2DScatter });
viewerSubmenu.addItem({ command: CommandIDs.new3DScatter });
viewerSubmenu.addItem({ command: CommandIDs.new2DImage });
viewerSubmenu.addItem({ command: CommandIDs.newTable });
this._menu.addItem({ type: 'submenu', submenu: viewerSubmenu });
Expand Down
32 changes: 31 additions & 1 deletion src/leftPanel/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function addCommands(

commands.addCommand(CommandIDs.new2DScatter, {
label: '2D Scatter',
iconClass: 'fa fa-circle',
iconClass: 'fa fa-chart-line',
execute: (args?: INewViewerArgs) => {
if (!controlModel.sharedModel) {
return;
Expand Down Expand Up @@ -81,6 +81,36 @@ function addCommands(
}
});

commands.addCommand(CommandIDs.new3DScatter, {
label: '3D Scatter',
iconClass: 'fa fa-chart-line',
execute: (args?: INewViewerArgs) => {
if (!controlModel.sharedModel) {
return;
}

const tabs = Object.keys(controlModel.sharedModel.tabs);
const focusedTab = controlModel.sharedModel.getSelectedTab() || 1;
const layer = args?.dataset || controlModel.selectedDataset;

if (focusedTab === 0) {
return;
}

controlModel.sharedModel.setTabItem(tabs[focusedTab - 1], UUID.uuid4(), {
_type: 'glue_vispy_viewers.scatter.scatter_viewer.VispyScatterViewer',
pos: args?.position || [0, 0],
session: 'Session',
size: args?.size || [600, 400],
state: {
values: {
layer
}
}
});
}
});

commands.addCommand(CommandIDs.new2DImage, {
label: '2D Image',
iconClass: 'fa fa-image',
Expand Down
5 changes: 4 additions & 1 deletion src/schemas/glue.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
"items": {
"anyOf": [
{
"$ref": "./viewers/scatter.schema.json"
"$ref": "./viewers/3dscatter.schema.json"
},
{
"$ref": "./viewers/2dscatter.schema.json"
},
{
"$ref": "./viewers/histogram.schema.json"
Expand Down
42 changes: 42 additions & 0 deletions src/schemas/viewers/3dscatter.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"type": "object",
"description": "Viewer::Scatter",
"title": "IGlueScatterViewer",
"required": ["_type", "layers", "pos", "session", "size", "state"],
"additionalProperties": false,
"properties": {
"_type": {
"const": "glue_vispy_viewers.scatter.scatter_viewer.VispyScatterViewer"
},
"layers": {
"type": "array",
"items": {
"type": "object"
}
},
"pos": {
"type": "array",
"items": {
"type": "number"
}
},
"session": {
"type": "string"
},
"size": {
"type": "array",
"items": {
"type": "number"
}
},
"state": {
"type": "object",
"additionalProperties": false,
"properties": {
"values": {
"type": "object"
}
}
}
}
}
1 change: 1 addition & 0 deletions src/viewPanel/sessionWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export class SessionWidget extends BoxPanel {
const items: IDict<string> = {
Histogram: CommandIDs.new1DHistogram,
'2D Scatter': CommandIDs.new2DScatter,
'3D Scatter': CommandIDs.new3DScatter,
'2D Image': CommandIDs.new2DImage,
Table: CommandIDs.newTable
};
Expand Down
Loading