diff --git a/glue_ar/common/export.py b/glue_ar/common/export.py index 5470b23..b2c50fd 100644 --- a/glue_ar/common/export.py +++ b/glue_ar/common/export.py @@ -40,7 +40,8 @@ def export_viewer(viewer_state: Vispy3DViewerState, bounds: Union[Bounds, BoundsWithResolution], state_dictionary: Dict[str, Tuple[str, State]], filepath: str, - compression: Optional[str]): + compression: Optional[str] = "None", + model_viewer: bool = False): base, ext = splitext(filepath) ext = ext[1:] @@ -71,8 +72,9 @@ def export_viewer(viewer_state: Vispy3DViewerState, if ext in ("gltf", "glb"): if (compression is not None) and (compression != "None"): compress_gl(filepath, method=compression) - mv_path = f"{base}{extsep}html" - export_modelviewer(mv_path, filepath, viewer_state.title) + if model_viewer: + mv_path = f"{base}{extsep}html" + export_modelviewer(mv_path, filepath, viewer_state.title) def compress_gltf_pipeline(filepath: str): diff --git a/glue_ar/common/export_state.py b/glue_ar/common/export_state.py index 39934c6..29a8449 100644 --- a/glue_ar/common/export_state.py +++ b/glue_ar/common/export_state.py @@ -1,4 +1,4 @@ -from echo import SelectionCallbackProperty +from echo import CallbackProperty, SelectionCallbackProperty from glue.core.data_combo_helper import ComboHelper from glue.core.state_objects import State from glue_vispy_viewers.common.layer_state import LayerState @@ -17,6 +17,7 @@ class ARExportDialogState(State): layer = SelectionCallbackProperty() compression = SelectionCallbackProperty() method = SelectionCallbackProperty() + modelviewer = CallbackProperty(True) def __init__(self, layers: Iterable[LayerState]): diff --git a/glue_ar/jupyter/export_dialog.py b/glue_ar/jupyter/export_dialog.py index 9b66beb..0044e0d 100644 --- a/glue_ar/jupyter/export_dialog.py +++ b/glue_ar/jupyter/export_dialog.py @@ -68,6 +68,9 @@ class JupyterARExportDialog(ARExportDialogBase, VuetifyTemplate): layer_layout = traitlets.Instance(v.Container).tag(sync=True, **widget_serialization) has_layer_options = traitlets.Bool().tag(sync=True) + modelviewer = traitlets.Bool(True).tag(sync=True) + show_modelviewer = traitlets.Bool(True).tag(sync=True) + def __init__(self, viewer: Viewer, display: Optional[bool] = False, @@ -83,6 +86,7 @@ def __init__(self, link_glue_choices(self, self.state, 'compression') link_glue_choices(self, self.state, 'filetype') link_glue_choices(self, self.state, 'method') + link((self, 'modelviewer'), (self.state, 'modelviewer')) self.dialog_open = display self.on_cancel = on_cancel @@ -112,6 +116,7 @@ def _on_filetype_change(self, filetype: str): super()._on_filetype_change(filetype) gl = filetype.lower() in ("gltf", "glb") self.show_compression = gl + self.show_modelviewer = gl def widgets_for_property(self, instance: HasCallbackProperties, diff --git a/glue_ar/jupyter/export_dialog.vue b/glue_ar/jupyter/export_dialog.vue index 21aacca..528682f 100644 --- a/glue_ar/jupyter/export_dialog.vue +++ b/glue_ar/jupyter/export_dialog.vue @@ -46,6 +46,13 @@ :items="compression_items" v-model="compression_selected" /> + + + Cancel diff --git a/glue_ar/jupyter/export_tool.py b/glue_ar/jupyter/export_tool.py index fdc277f..6bae730 100644 --- a/glue_ar/jupyter/export_tool.py +++ b/glue_ar/jupyter/export_tool.py @@ -116,4 +116,5 @@ def save_figure(self, filepath): bounds=bounds, state_dictionary=state_dict, filepath=filepath, - compression=self.export_dialog.state.compression) + compression=self.export_dialog.state.compression, + model_viewer=self.export_dialog.state.modelviewer) diff --git a/glue_ar/jupyter/tests/test_dialog.py b/glue_ar/jupyter/tests/test_dialog.py index e12d09e..e2fd098 100644 --- a/glue_ar/jupyter/tests/test_dialog.py +++ b/glue_ar/jupyter/tests/test_dialog.py @@ -67,21 +67,27 @@ def test_filetype_change(self): state.filetype = "USDC" assert not self.dialog.show_compression + assert not self.dialog.show_modelviewer state.filetype = "USDA" assert not self.dialog.show_compression + assert not self.dialog.show_modelviewer state.filetype = "glTF" assert self.dialog.show_compression + assert self.dialog.show_modelviewer state.filetype = "USDA" assert not self.dialog.show_compression + assert not self.dialog.show_modelviewer state.filetype = "STL" assert not self.dialog.show_compression + assert not self.dialog.show_modelviewer state.filetype = "glTF" assert self.dialog.show_compression + assert self.dialog.show_modelviewer def test_widgets_for_property(self): state = DummyState() diff --git a/glue_ar/qt/export_dialog.py b/glue_ar/qt/export_dialog.py index 03c455b..2668e3b 100644 --- a/glue_ar/qt/export_dialog.py +++ b/glue_ar/qt/export_dialog.py @@ -100,6 +100,7 @@ def _on_filetype_change(self, filetype: str): gl = filetype.lower() in ("gltf", "glb") self.ui.combosel_compression.setVisible(gl) self.ui.label_compression_message.setVisible(gl) + self.ui.bool_modelviewer.setVisible(gl) def _on_method_change(self, method_name: str): super()._on_method_change(method_name) diff --git a/glue_ar/qt/export_dialog.ui b/glue_ar/qt/export_dialog.ui index feb78c1..01e98c8 100644 --- a/glue_ar/qt/export_dialog.ui +++ b/glue_ar/qt/export_dialog.ui @@ -14,10 +14,71 @@ Export 3D File + + + + <html><head/><body><p align="center"><span style=" font-weight:600;">Layer Options</span></p></body></html> + + + + + + + + + + Qt::Horizontal + + + - + + + + Select export options + + + + + + + Filetype + + + + + + + + + + + + + + + + <html><head/><body><p align="center"><span style=" font-weight:600;">File Options</span></p></body></html> + + + + + + + Export method: + + + + + + + Compression method + + + + @@ -56,64 +117,13 @@ - - - - Filetype - - - - - - - - - - Qt::Horizontal - - - - - - - Compression method - - - - - - - Export method: - - - - - - - - - - Select export options - - - - - - - - + + - <html><head/><body><p align="center"><span style=" font-weight:600;">File Options</span></p></body></html> + Export model-viewer HTML - - - - - - - - - <html><head/><body><p align="center"><span style=" font-weight:600;">Layer Options</span></p></body></html> + + true diff --git a/glue_ar/qt/export_tool.py b/glue_ar/qt/export_tool.py index 60c5586..e4c7a14 100644 --- a/glue_ar/qt/export_tool.py +++ b/glue_ar/qt/export_tool.py @@ -63,7 +63,8 @@ def activate(self): bounds=bounds, state_dictionary=dialog.state_dictionary, filepath=export_path, - compression=dialog.state.compression) + compression=dialog.state.compression, + model_viewer=dialog.state.modelviewer) def _start_worker(self, exporter, **kwargs): _, ext = splitext(kwargs["filepath"]) diff --git a/glue_ar/qt/tests/test_tool_scatter.py b/glue_ar/qt/tests/test_tool_scatter.py index b49027c..c67cb82 100644 --- a/glue_ar/qt/tests/test_tool_scatter.py +++ b/glue_ar/qt/tests/test_tool_scatter.py @@ -88,6 +88,7 @@ def test_tool_export_call(self, extension, compression): assert kwargs["bounds"] == bounds assert kwargs["filepath"] == filepath assert kwargs["compression"] == compression + assert kwargs["model_viewer"] state_dict = kwargs["state_dictionary"] assert tuple(state_dict.keys()) == ("Scatter Data 1", "Scatter Data 2") for value in state_dict.values():