-
Notifications
You must be signed in to change notification settings - Fork 202
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
EMSUSD-1518 As an artist, I want the ability to determine whether a collection includes all objects by default or not #3988
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
33d55e6
including light linking spike demo code
haberlu e795d1a
Added include all button
barbalt 9975b2b
Fix test
barbalt 3faa843
create file for control
barbalt f4c1455
better exception message
barbalt 268e3d9
Adjust maya version in test
barbalt 759083f
Only support LL in 2023+
barbalt cccc766
Missed removing cmake install
barbalt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
.../resources/ae/usd-shared-components/src/python/usdSharedComponents/collection/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Shared common components for USD plugins for 3dsMax and Maya |
48 changes: 48 additions & 0 deletions
48
...sd/resources/ae/usd-shared-components/src/python/usdSharedComponents/collection/widget.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from ..common.list import StringList | ||
from ..common.resizable import Resizable | ||
|
||
try: | ||
from PySide6.QtWidgets import QWidget, QVBoxLayout | ||
except ImportError: | ||
from PySide2.QtWidgets import QWidget, QVBoxLayout # type: ignore | ||
|
||
from pxr import Usd | ||
|
||
class CollectionWidget(QWidget): | ||
def __init__(self, collection: Usd.CollectionAPI = None, parent: QWidget = None): | ||
super(CollectionWidget, self).__init__(parent) | ||
|
||
self._collection: Usd.CollectionAPI = collection | ||
|
||
includes = [] | ||
excludes = [] | ||
shouldIncludeAll = False | ||
|
||
if self._collection is not None: | ||
includeRootAttribute = self._collection.GetIncludeRootAttr() | ||
if includeRootAttribute.IsAuthored(): | ||
shouldIncludeAll = self._collection.GetIncludeRootAttr().Get() | ||
|
||
for p in self._collection.GetIncludesRel().GetTargets(): | ||
includes.append(p.pathString) | ||
for p in self._collection.GetExcludesRel().GetTargets(): | ||
excludes.append(p.pathString) | ||
|
||
self.mainLayout = QVBoxLayout(self) | ||
self.mainLayout.setContentsMargins(0,0,0,0) | ||
|
||
self._include = StringList( includes, "Include", "Include all", self) | ||
self._include.cbIncludeAll.setChecked(shouldIncludeAll) | ||
self._include.cbIncludeAll.stateChanged.connect(self.onIncludeAllToggle) | ||
self._resizableInclude = Resizable(self._include, "USD_Light_Linking", "IncludeListHeight", self) | ||
|
||
self.mainLayout.addWidget(self._resizableInclude) | ||
|
||
self._exclude = StringList( excludes, "Exclude", "", self) | ||
self._resizableExclude = Resizable(self._exclude, "USD_Light_Linking", "ExcludeListHeight", self) | ||
|
||
self.mainLayout.addWidget(self._resizableExclude) | ||
self.mainLayout.addStretch(1) | ||
|
||
def onIncludeAllToggle(self): | ||
self._collection.GetIncludeRootAttr().Set(self._include.cbIncludeAll.isChecked()) |
1 change: 1 addition & 0 deletions
1
...aUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/common/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Shared common components for USD plugins for 3dsMax and Maya |
94 changes: 94 additions & 0 deletions
94
lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/common/list.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
from typing import Sequence | ||
from .theme import Theme | ||
|
||
try: | ||
from PySide6.QtCore import ( | ||
QModelIndex, | ||
QPersistentModelIndex, | ||
QSize, | ||
QStringListModel, | ||
Qt, | ||
Signal, | ||
) | ||
from PySide6.QtGui import QPainter | ||
from PySide6.QtWidgets import QStyleOptionViewItem, QStyledItemDelegate, QListView, QLabel, QVBoxLayout, QHBoxLayout, QWidget, QCheckBox | ||
except: | ||
from PySide2.QtGui import QPainter # type: ignore | ||
from PySide2.QtWidgets import QStyleOptionViewItem, QStyledItemDelegate, QListView, QLabel, QVBoxLayout, QHBoxLayout, QWidget, QCheckBox # type: ignore | ||
|
||
class _StringList(QListView): | ||
selectedItemsChanged = Signal() | ||
|
||
class Delegate(QStyledItemDelegate): | ||
def __init__(self, model: QStringListModel, parent=None): | ||
super(_StringList.Delegate, self).__init__(parent) | ||
self._model = model | ||
|
||
def sizeHint(self, option: QStyleOptionViewItem, index: QModelIndex | QPersistentModelIndex): | ||
s: int = Theme.instance().uiScaled(24) | ||
return QSize(s, s) | ||
|
||
def paint(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelIndex | QPersistentModelIndex): | ||
s: str = self._model.data(index, Qt.DisplayRole) | ||
Theme.instance().paintStringListEntry(painter, option.rect, s) | ||
|
||
def __init__(self, items: Sequence[str] = [], parent=None): | ||
super(_StringList, self).__init__(parent) | ||
self._model = QStringListModel(items, self) | ||
self.setModel(self._model) | ||
|
||
self.setUniformItemSizes(True) | ||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) | ||
self.setTextElideMode(Qt.TextElideMode.ElideMiddle) | ||
self.setSelectionBehavior(QListView.SelectRows) | ||
self.setSelectionMode(QListView.MultiSelection) | ||
self.setContentsMargins(0,0,0,0) | ||
|
||
self.selectionModel().selectionChanged.connect(lambda: self.selectedItemsChanged.emit()) | ||
|
||
def drawFrame(self, painter: QPainter): | ||
pass | ||
|
||
@property | ||
def items(self) -> Sequence[str]: | ||
return self._model.stringList | ||
|
||
@items.setter | ||
def items(self, items: Sequence[str]): | ||
self._model.setStringList(items) | ||
|
||
@property | ||
def selectedItems(self) -> Sequence[str]: | ||
return [index.data(Qt.DisplayRole) for index in self.selectedIndexes()] | ||
|
||
|
||
class StringList(QWidget): | ||
|
||
def __init__(self, items: Sequence[str] = [], headerTitle: str = "", toggleTitle: str = "", parent=None): | ||
super().__init__() | ||
self.list = _StringList(items, self) | ||
|
||
layout = QVBoxLayout(self) | ||
LEFT_RIGHT_MARGINS = 2 | ||
layout.setContentsMargins(LEFT_RIGHT_MARGINS, 0, LEFT_RIGHT_MARGINS, 0) | ||
|
||
headerWidget = QWidget(self) | ||
headerLayout = QHBoxLayout(headerWidget) | ||
|
||
titleLabel = QLabel(headerTitle, self) | ||
headerLayout.addWidget(titleLabel) | ||
headerLayout.addStretch(1) | ||
headerLayout.setContentsMargins(0,0,0,0) | ||
|
||
# only add the check box on the header if there's a label | ||
if toggleTitle != None and toggleTitle != "": | ||
self.cbIncludeAll = QCheckBox(toggleTitle, self) | ||
self.cbIncludeAll.setCheckable(True) | ||
headerLayout.addWidget(self.cbIncludeAll) | ||
|
||
headerWidget.setLayout(headerLayout) | ||
|
||
layout.addWidget(headerWidget) | ||
layout.addWidget(self.list) | ||
|
||
self.setLayout(layout) |
36 changes: 36 additions & 0 deletions
36
...urces/ae/usd-shared-components/src/python/usdSharedComponents/common/persistentStorage.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
try: | ||
from PySide6.QtCore import QSettings | ||
except: | ||
from PySide2.QtCore import QSettings # type: ignore | ||
|
||
|
||
class PersistentStorage(object): | ||
_instance = None | ||
|
||
def __init__(self): | ||
raise RuntimeError("Call instance() instead") | ||
|
||
@classmethod | ||
def instance(cls): | ||
if cls._instance is None: | ||
cls._instance = cls.__new__(cls) | ||
return cls._instance | ||
|
||
@classmethod | ||
def injectInstance(cls, persistentStorage): | ||
cls._instance = persistentStorage | ||
|
||
def _settings(self) -> QSettings: | ||
return QSettings("settings.ini", QSettings.IniFormat) | ||
|
||
def set(self, group: str, key: str, value: object): | ||
settings: QSettings = self._settings() | ||
settings.beginGroup(group) | ||
settings.setValue(key, value) | ||
settings.endGroup() | ||
settings.sync() | ||
|
||
def get(self, group: str, key: str, default: object = None) -> object: | ||
settings: QSettings = self._settings() | ||
settings.beginGroup(group) | ||
return settings.value(key, default, type=type(default)) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As agreed, we won't support this for 2022, so just wrap all this in
if(MAYA_APP_VERSION VERSION_GREATER_EQUAL 2023)