Skip to content

Commit

Permalink
EditScopeUI : Hide locations EditScope shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmehl committed Jul 7, 2023
1 parent 169a5d5 commit 8335938
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 19 deletions.
5 changes: 5 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -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 <kbd>Ctrl</kbd>+<kbd>H</kbd> shortcut.

Fixes
-----

Expand Down
39 changes: 20 additions & 19 deletions doc/source/Interface/ControlsAndShortcuts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*<br>or<br>{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`<br>or<br>{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*<br>or<br>{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`<br>or<br>{kbd}`Ctrl` + {kbd}`Backspace`
Turn off visibility for selected objects from current EditScope | {kbd}`Ctrl` + {kbd}`H`

### Transform tools ###

Expand Down
53 changes: 53 additions & 0 deletions python/GafferSceneUI/EditScopeUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#
##########################################################################

import IECore

import Gaffer
import GafferUI
import GafferScene
Expand All @@ -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" ) :
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions src/GafferScene/EditScopeAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ namespace
/// in clients of history related APIs such as `AttributeInspector`.
using CreatableRegistry = std::unordered_map<std::string, const IECore::DataPtr>;
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" ) },
Expand Down
1 change: 1 addition & 0 deletions startup/gui/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 )

0 comments on commit 8335938

Please sign in to comment.