From 6e46dca1bd816a186920eecffce2376d01185afe Mon Sep 17 00:00:00 2001 From: abdellah Date: Tue, 14 Apr 2020 11:31:03 +0200 Subject: [PATCH] Online documentation. --- .../ui/analysis/analysis_panel_ops.py | 4 ++- nmv/interface/ui/edit/edit_panel.py | 15 +++++++-- nmv/interface/ui/io/io_panel.py | 4 +-- nmv/interface/ui/mesh/mesh_panel.py | 4 +-- .../ui/morphology/morphology_panel.py | 4 +-- nmv/interface/ui/soma/soma_panel.py | 4 +-- nmv/scene/ops/scene_ops.py | 31 +++++++++++++++++++ 7 files changed, 55 insertions(+), 11 deletions(-) diff --git a/nmv/interface/ui/analysis/analysis_panel_ops.py b/nmv/interface/ui/analysis/analysis_panel_ops.py index 59e78fae9..f65bda897 100644 --- a/nmv/interface/ui/analysis/analysis_panel_ops.py +++ b/nmv/interface/ui/analysis/analysis_panel_ops.py @@ -366,7 +366,9 @@ def sketch_morphology_skeleton_guide(morphology, nmv.scene.clear_scene() # Create a skeletonizer object to build the morphology skeleton - builder = nmv.builders.DisconnectedSectionsBuilder(morphology, options) + options_clone = copy.deepcopy(options) + options_clone.morphology.branching = nmv.enums.Skeleton.Branching.RADII + builder = nmv.builders.ConnectedSectionsBuilder(morphology, options_clone) # Draw the morphology skeleton and return a list of all the reconstructed objects nmv.interface.ui_reconstructed_skeleton = builder.draw_morphology_skeleton() diff --git a/nmv/interface/ui/edit/edit_panel.py b/nmv/interface/ui/edit/edit_panel.py index 975091066..4b553189e 100644 --- a/nmv/interface/ui/edit/edit_panel.py +++ b/nmv/interface/ui/edit/edit_panel.py @@ -192,6 +192,14 @@ def execute(self, # Clear the scene nmv.scene.ops.clear_scene() + # Switch to the wire-frame mode + nmv.scene.switch_interface_to_edit_mode() + + # Sketch the guide to make sure users can see something + nmv.interface.ui.sketch_morphology_skeleton_guide( + morphology=nmv.interface.ui_morphology, + options=copy.deepcopy(nmv.interface.ui_options)) + # Sketch the morphological skeleton for repair morphology_editor = nmv.edit.MorphologyEditor( morphology=nmv.interface.ui_morphology, options=nmv.interface.ui_options) @@ -235,6 +243,9 @@ def execute(self, 'FINISHED' """ + # Switch back to the solid mode + nmv.scene.switch_interface_to_visualization_mode() + # Create an object of the repairer global morphology_editor @@ -312,11 +323,11 @@ def execute(self, # @MorphologyEditingDocumentation #################################################################################################### class MorphologyEditingDocumentation(bpy.types.Operator): - """Open the documentation page of the Morphology Editing panel.""" + """Open the online documentation page of the Morphology Editing panel.""" # Operator parameters bl_idname = "nmv.documentation_editing" - bl_label = "Documentation" + bl_label = "Online User Guide" ################################################################################################ # @execute diff --git a/nmv/interface/ui/io/io_panel.py b/nmv/interface/ui/io/io_panel.py index 7048fb6ef..f1c577763 100644 --- a/nmv/interface/ui/io/io_panel.py +++ b/nmv/interface/ui/io/io_panel.py @@ -266,11 +266,11 @@ def execute(self, # @InputOutputDocumentation #################################################################################################### class InputOutputDocumentation(bpy.types.Operator): - """Open the documentation page of the IO module.""" + """Open the online documentation page of the IO panel.""" # Operator parameters bl_idname = "nmv.documentation_io" - bl_label = "Documentation" + bl_label = "Online User Guide" ################################################################################################ # @execute diff --git a/nmv/interface/ui/mesh/mesh_panel.py b/nmv/interface/ui/mesh/mesh_panel.py index 79a056309..673ddc4c0 100644 --- a/nmv/interface/ui/mesh/mesh_panel.py +++ b/nmv/interface/ui/mesh/mesh_panel.py @@ -582,11 +582,11 @@ def execute(self, context): # @InputOutputDocumentation #################################################################################################### class MeshReconstructionDocumentation(bpy.types.Operator): - """Open the documentation page of the Mesh Reconstruction panel.""" + """Open the online documentation page of the Mesh Reconstruction panel.""" # Operator parameters bl_idname = "nmv.documentation_mesh" - bl_label = "Documentation" + bl_label = "Online User Guide" ################################################################################################ # @execute diff --git a/nmv/interface/ui/morphology/morphology_panel.py b/nmv/interface/ui/morphology/morphology_panel.py index 7acea466e..b2d8e8dea 100644 --- a/nmv/interface/ui/morphology/morphology_panel.py +++ b/nmv/interface/ui/morphology/morphology_panel.py @@ -844,11 +844,11 @@ def execute(self, # @MorphologyReconstructionDocumentation #################################################################################################### class MorphologyReconstructionDocumentation(bpy.types.Operator): - """Open the documentation page of the Morphology Reconstruction panel.""" + """Open the online documentation page of the Morphology Reconstruction panel.""" # Operator parameters bl_idname = "nmv.documentation_morphology" - bl_label = "Documentation" + bl_label = "Online User Guide" ################################################################################################ # @execute diff --git a/nmv/interface/ui/soma/soma_panel.py b/nmv/interface/ui/soma/soma_panel.py index 5908aebd7..cf21b2cc4 100644 --- a/nmv/interface/ui/soma/soma_panel.py +++ b/nmv/interface/ui/soma/soma_panel.py @@ -1104,11 +1104,11 @@ def execute(self, # @SomaReconstructionDocumentation #################################################################################################### class SomaReconstructionDocumentation(bpy.types.Operator): - """Open the documentation page of the Soma Reconstruction panel.""" + """Open the online documentation page of the Soma Reconstruction panel.""" # Operator parameters bl_idname = "nmv.documentation_soma" - bl_label = "Documentation" + bl_label = "Online User Guide" ################################################################################################ # @execute diff --git a/nmv/scene/ops/scene_ops.py b/nmv/scene/ops/scene_ops.py index 9866892eb..550adf654 100644 --- a/nmv/scene/ops/scene_ops.py +++ b/nmv/scene/ops/scene_ops.py @@ -1162,3 +1162,34 @@ def view_all_scene(): # View all the objects in the scene bpy.ops.view3d.view_all() + + +#################################################################################################### +# @switch_scene_shading +#################################################################################################### +def switch_scene_shading(shading_type='SOLID'): + """Switches the scene panel to the given shading type + + :param shading_type: + One of the following: 'WIREFRAME' '(SOLID)' 'MATERIAL' 'RENDERED' + """ + + areas = bpy.context.workspace.screens[0].areas + for area in areas: + for space in area.spaces: + if space.type == 'VIEW_3D': + space.shading.type = shading_type + + +def switch_interface_to_edit_mode(): + nmv.scene.switch_scene_shading('WIREFRAME') + bpy.context.preferences.themes['Default'].view_3d.vertex_size = 8 + + +def switch_interface_to_visualization_mode(): + nmv.scene.switch_scene_shading('SOLID') + + bpy.context.preferences.themes['Default'].view_3d.vertex.r = 0 + bpy.context.preferences.themes['Default'].view_3d.vertex.g = 0 + bpy.context.preferences.themes['Default'].view_3d.vertex.b = 0 + bpy.context.preferences.themes['Default'].view_3d.vertex_size = 3