From 833593820d6fc2cca4882c3e0d1784a640437c4d Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Fri, 30 Jun 2023 14:53:11 -0400 Subject: [PATCH] EditScopeUI : Hide locations EditScope shortcut --- Changes.md | 5 ++ .../Interface/ControlsAndShortcuts/index.md | 39 +++++++------- python/GafferSceneUI/EditScopeUI.py | 53 +++++++++++++++++++ src/GafferScene/EditScopeAlgo.cpp | 1 + startup/gui/viewer.py | 1 + 5 files changed, 80 insertions(+), 19 deletions(-) diff --git a/Changes.md b/Changes.md index 6b265bf9b66..74458c393d1 100644 --- a/Changes.md +++ b/Changes.md @@ -1,6 +1,11 @@ 1.2.x.x (relative to 1.2.9.0) ======= +Improvements +------------ + +- EditScopeUI : Added the ability to turn off visibility of selected objects in the viewer using the Ctrl+H shortcut. + Fixes ----- diff --git a/doc/source/Interface/ControlsAndShortcuts/index.md b/doc/source/Interface/ControlsAndShortcuts/index.md index 1810366f819..4d5de2154d0 100644 --- a/doc/source/Interface/ControlsAndShortcuts/index.md +++ b/doc/source/Interface/ControlsAndShortcuts/index.md @@ -227,25 +227,26 @@ Pin to numeric bookmark | {kbd}`1` … {kbd}`9` ### 3D scenes ### -Action | Control or shortcut ------------------------------------------------------|-------------------- -Tumble | {kbd}`Alt` + {{leftClick}} and drag -Tumble, fine precision | Hold {kbd}`Shift` during action -Select objects | {{leftClick}} and drag marquee, then release -Add/remove object from selection | {kbd}`Ctrl` + {{leftClick}} -Add objects to selection | {kbd}`Shift` + {{leftClick}} and drag marquee, then release -Deselect objects | {kbd}`Ctrl` + {{leftClick}} and drag marquee, then release -Expand selection | {kbd}`↓` -Fully expand selection | {kbd}`Shift` + {kbd}`↓` -Collapse selection | {kbd}`↑` -Edit source node of selection | {kbd}`Alt` + {kbd}`E` -Edit tweaks node for selection | {kbd}`Alt` + {kbd}`Shift` + {kbd}`E` -Fit clipping planes to scene | {{rightClick}} > *Clipping Planes* > *Fit To Scene* -Fit clipping planes to selection | {{rightClick}} > *Clipping Planes* > *Fit To Selection*
or
{kbd}`Ctrl` + {kbd}`K` -Frame view, and fit clipping planes | {kbd}`Ctrl` + {kbd}`F` -Reset clipping planes | {{rightClick}} > *Clipping Planes* > *Default* -Toggle Inspector | {kbd}`I` -Prune selected objects from current EditScope | {kbd}`Ctrl` + {kbd}`Delete`
or
{kbd}`Ctrl` + {kbd}`Backspace` +Action | Control or shortcut +-----------------------------------------------------------------|-------------------- +Tumble | {kbd}`Alt` + {{leftClick}} and drag +Tumble, fine precision | Hold {kbd}`Shift` during action +Select objects | {{leftClick}} and drag marquee, then release +Add/remove object from selection | {kbd}`Ctrl` + {{leftClick}} +Add objects to selection | {kbd}`Shift` + {{leftClick}} and drag marquee, then release +Deselect objects | {kbd}`Ctrl` + {{leftClick}} and drag marquee, then release +Expand selection | {kbd}`↓` +Fully expand selection | {kbd}`Shift` + {kbd}`↓` +Collapse selection | {kbd}`↑` +Edit source node of selection | {kbd}`Alt` + {kbd}`E` +Edit tweaks node for selection | {kbd}`Alt` + {kbd}`Shift` + {kbd}`E` +Fit clipping planes to scene | {{rightClick}} > *Clipping Planes* > *Fit To Scene* +Fit clipping planes to selection | {{rightClick}} > *Clipping Planes* > *Fit To Selection*
or
{kbd}`Ctrl` + {kbd}`K` +Frame view, and fit clipping planes | {kbd}`Ctrl` + {kbd}`F` +Reset clipping planes | {{rightClick}} > *Clipping Planes* > *Default* +Toggle Inspector | {kbd}`I` +Prune selected objects from current EditScope | {kbd}`Ctrl` + {kbd}`Delete`
or
{kbd}`Ctrl` + {kbd}`Backspace` +Turn off visibility for selected objects from current EditScope | {kbd}`Ctrl` + {kbd}`H` ### Transform tools ### diff --git a/python/GafferSceneUI/EditScopeUI.py b/python/GafferSceneUI/EditScopeUI.py index b4026cf470a..946d1ed6a28 100644 --- a/python/GafferSceneUI/EditScopeUI.py +++ b/python/GafferSceneUI/EditScopeUI.py @@ -34,6 +34,8 @@ # ########################################################################## +import IECore + import Gaffer import GafferUI import GafferScene @@ -44,6 +46,11 @@ def addPruningActions( editor ) : if isinstance( editor, GafferUI.Viewer ) : editor.keyPressSignal().connect( __pruningKeyPress, scoped = False ) +def addVisibilityActions( editor ) : + + if isinstance( editor, GafferUI.Viewer ) : + editor.keyPressSignal().connect( __visibilityKeyPress, scoped = False ) + def __pruningKeyPress( viewer, event ) : if event.key not in ( "Backspace", "Delete" ) : @@ -101,3 +108,49 @@ def __pruningKeyPress( viewer, event ) : GafferScene.EditScopeAlgo.setPruned( editScope, selection, True ) return True + +def __visibilityKeyPress( viewer, event ) : + + if not ( event.key == "H" and event.Modifiers.Control ) : + return False + + if not isinstance( viewer.view(), GafferSceneUI.SceneView ) : + return False + + editScope = viewer.view().editScope() + if editScope is None or Gaffer.MetadataAlgo.readOnly( editScope ) : + return True + + sceneGadget = viewer.view().viewportGadget().getPrimaryChild() + selection = sceneGadget.getSelection() + + if selection.isEmpty() : + return True + + inspector = GafferSceneUI.Private.AttributeInspector( + viewer.view()["in"].getInput(), + viewer.view()["editScope"], + "scene:visible" + ) + + with viewer.getContext() as context : + attributeEdits = editScope.acquireProcessor( "AttributeEdits", createIfNecessary = False ) + if not editScope["enabled"].getValue() or ( attributeEdits is not None and not attributeEdits["enabled"].getValue() ) : + # Spare folks from hiding something when it won't be + # apparent what they've done until they reenable the + # EditScope or processor. + return True + + with Gaffer.UndoScope( editScope.ancestor( Gaffer.ScriptNode ) ) : + for path in selection.paths() : + context["scene:path"] = IECore.InternedStringVectorData( path.split( "/" )[1:] ) + inspection = inspector.inspect() + + if inspection is None or not inspection.editable() : + continue + + tweakPlug = inspection.acquireEdit() + tweakPlug["enabled"].setValue( True ) + tweakPlug["value"].setValue( False ) + + return True diff --git a/src/GafferScene/EditScopeAlgo.cpp b/src/GafferScene/EditScopeAlgo.cpp index bba982f3856..f037f2e154d 100644 --- a/src/GafferScene/EditScopeAlgo.cpp +++ b/src/GafferScene/EditScopeAlgo.cpp @@ -87,6 +87,7 @@ namespace /// in clients of history related APIs such as `AttributeInspector`. using CreatableRegistry = std::unordered_map; CreatableRegistry g_attributeRegistry { + { "scene:visible", new BoolData( true ) }, { "gl:visualiser:scale", new IECore::FloatData( 1.0f ) }, { "gl:visualiser:maxTextureResolution", new IECore::IntData( 512 ) }, { "gl:visualiser:frustum", new IECore::StringData( "whenSelected" ) }, diff --git a/startup/gui/viewer.py b/startup/gui/viewer.py index 8b5092fe7e5..bd38907bb17 100644 --- a/startup/gui/viewer.py +++ b/startup/gui/viewer.py @@ -226,3 +226,4 @@ def __loadRendererSettings( fileName ) : # Add catalogue hotkeys to viewers, eg: up/down navigation GafferUI.Editor.instanceCreatedSignal().connect( GafferImageUI.CatalogueUI.addCatalogueHotkeys, scoped = False ) GafferUI.Editor.instanceCreatedSignal().connect( GafferSceneUI.EditScopeUI.addPruningActions, scoped = False ) +GafferUI.Editor.instanceCreatedSignal().connect( GafferSceneUI.EditScopeUI.addVisibilityActions, scoped = False )