Skip to content
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

MAYA-128473 - Move UFE to its own Project - Part11 (UIInfoHandler) #3252

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 1 addition & 31 deletions lib/mayaUsd/resources/icons/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,9 @@
# install
# ---------------------------------------------------------------------------------------------

# Maya Outliner icons
# Maya Outliner icons (most come from UsdUfe)
set(OUTLINER_ICONS
BlendShape
Camera
Capsule
CompArcBadge
CompArcBadgeV
Cone
Cube
Cylinder
Def
GeomSubset
LightFilter
LightPortal
MayaReference
Mesh
NurbsPatch
PluginLight
PointInstancer
Points
Scope
SkelAnimation
Skeleton
SkelRoot
Sphere
UsdGeomCurves
UsdGeomXformable
UsdLuxBoundableLightBase
UsdLuxNonboundableLightBase
UsdTyped
Volume
Material
Shader
)
foreach(ICON_BASE ${OUTLINER_ICONS})
# The _100.png files need to be installed without the _100. This is the
Expand Down
4 changes: 2 additions & 2 deletions lib/mayaUsd/ufe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ target_sources(${PROJECT_NAME}
MayaUsdContextOpsHandler.cpp
MayaUsdObject3d.cpp
MayaUsdObject3dHandler.cpp
MayaUsdUIInfoHandler.cpp
ProxyShapeContextOpsHandler.cpp
ProxyShapeHandler.cpp
ProxyShapeHierarchy.cpp
Expand Down Expand Up @@ -39,7 +40,6 @@ target_sources(${PROJECT_NAME}
UsdTransform3dSetObjectMatrix.cpp
UsdTransform3dUndoableCommands.cpp
UsdTranslateUndoableCommand.cpp
UsdUIInfoHandler.cpp
UsdUIUfeObserver.cpp
UsdUndoDeleteCommand.cpp
UsdUndoDuplicateCommand.cpp
Expand Down Expand Up @@ -171,6 +171,7 @@ set(HEADERS
MayaUsdContextOpsHandler.h
MayaUsdObject3d.h
MayaUsdObject3dHandler.h
MayaUsdUIInfoHandler.h
ProxyShapeContextOpsHandler.h
ProxyShapeHandler.h
ProxyShapeHierarchy.h
Expand Down Expand Up @@ -203,7 +204,6 @@ set(HEADERS
UsdTransform3dSetObjectMatrix.h
UsdTransform3dUndoableCommands.h
UsdTranslateUndoableCommand.h
UsdUIInfoHandler.h
UsdUIUfeObserver.h
UsdUndoDeleteCommand.h
UsdUndoDuplicateCommand.h
Expand Down
4 changes: 2 additions & 2 deletions lib/mayaUsd/ufe/Global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <mayaUsd/ufe/MayaStagesSubject.h>
#include <mayaUsd/ufe/MayaUsdContextOpsHandler.h>
#include <mayaUsd/ufe/MayaUsdObject3dHandler.h>
#include <mayaUsd/ufe/MayaUsdUIInfoHandler.h>
#include <mayaUsd/ufe/ProxyShapeContextOpsHandler.h>
#include <mayaUsd/ufe/ProxyShapeHandler.h>
#include <mayaUsd/ufe/ProxyShapeHierarchyHandler.h>
Expand All @@ -31,7 +32,6 @@
#include <mayaUsd/ufe/UsdTransform3dMatrixOp.h>
#include <mayaUsd/ufe/UsdTransform3dMayaXformStack.h>
#include <mayaUsd/ufe/UsdTransform3dPointInstance.h>
#include <mayaUsd/ufe/UsdUIInfoHandler.h>
#include <mayaUsd/ufe/UsdUIUfeObserver.h>
#include <mayaUsd/ufe/Utils.h>
#include <mayaUsd/utils/editability.h>
Expand Down Expand Up @@ -198,7 +198,7 @@ MStatus initialize()
handlers.attributesHandler = UsdAttributesHandler::create();
usdUfeHandlers.object3dHandler = MayaUsdObject3dHandler::create();
usdUfeHandlers.contextOpsHandler = MayaUsdContextOpsHandler::create();
handlers.uiInfoHandler = UsdUIInfoHandler::create();
usdUfeHandlers.uiInfoHandler = MayaUsdUIInfoHandler::create();

#ifdef UFE_V4_FEATURES_AVAILABLE

Expand Down
92 changes: 92 additions & 0 deletions lib/mayaUsd/ufe/MayaUsdUIInfoHandler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//
// Copyright 2023 Autodesk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "MayaUsdUIInfoHandler.h"

#include <maya/MDoubleArray.h>
#include <maya/MGlobal.h>

namespace MAYAUSD_NS_DEF {
namespace ufe {

MayaUsdUIInfoHandler::MayaUsdUIInfoHandler()
: UsdUfe::UsdUIInfoHandler()
{
// Register a callback to invalidate the invisible color.
fColorChangedCallbackId = MEventMessage::addEventCallback(
"DisplayRGBColorChanged", onColorChanged, reinterpret_cast<void*>(this));
Comment on lines +27 to +29
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split off Maya stuff into this derived class. Mostly to handle this Maya callback when the color prefs changed.


// Immediately update the invisible color to get a starting current value.
updateInvisibleColor();
}

MayaUsdUIInfoHandler::~MayaUsdUIInfoHandler()
{
// Unregister the callback used to invalidate the invisible color.
if (fColorChangedCallbackId)
MMessage::removeCallback(fColorChangedCallbackId);
}

/*static*/
MayaUsdUIInfoHandler::Ptr MayaUsdUIInfoHandler::create()
{
return std::make_shared<MayaUsdUIInfoHandler>();
}

void MayaUsdUIInfoHandler::updateInvisibleColor()
{
// Retrieve the invisible color of the Maya Outliner.
//
// We *cannot* intialize it in treeViewCellInfo() because
// that function gets called in a paint event and calling
// a command in a painting event can cause a recursive paint
// event if commands echoing is on, which can corrupt the
// Qt paint internal which lead to a crash. Typical symptom
// is that the state variable of the Qt paint engine becomes
// null midway through the repaint.

MDoubleArray color;
MGlobal::executeCommand("displayRGBColor -q \"outlinerInvisibleColor\"", color);

if (color.length() == 3) {
color.get(fInvisibleColor.data());
}
}

/*static*/
void MayaUsdUIInfoHandler::onColorChanged(void* data)
{
MayaUsdUIInfoHandler* infoHandler = reinterpret_cast<MayaUsdUIInfoHandler*>(data);
if (!infoHandler)
return;

infoHandler->updateInvisibleColor();
}

UsdUfe::UsdUIInfoHandler::SupportedTypesMap MayaUsdUIInfoHandler::getSupportedIconTypes() const
{
auto supportedTypes = Parent::getSupportedIconTypes();

// We support these node types directly.
static const UsdUfe::UsdUIInfoHandler::SupportedTypesMap mayaSupportedTypes {
{ "MayaReference", "out_USD_MayaReference.png" },
{ "ALMayaReference", "out_USD_MayaReference.png" }, // Same as mayaRef
};
supportedTypes.insert(mayaSupportedTypes.begin(), mayaSupportedTypes.end());
return supportedTypes;
}
Comment on lines +78 to +89
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overridden method to add the two Maya reference icon types.


} // namespace ufe
} // namespace MAYAUSD_NS_DEF
63 changes: 63 additions & 0 deletions lib/mayaUsd/ufe/MayaUsdUIInfoHandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#ifndef MAYAUSDUIINFOHANDLER_H
#define MAYAUSDUIINFOHANDLER_H

//
// Copyright 2023 Autodesk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#include <mayaUsd/base/api.h>

#include <usdUfe/ufe/UsdUIInfoHandler.h>

#include <maya/MEventMessage.h>

namespace MAYAUSD_NS_DEF {
namespace ufe {

//! \brief Implementation of Ufe::UIInfoHandler interface for USD objects.
class MAYAUSD_CORE_PUBLIC MayaUsdUIInfoHandler : public UsdUfe::UsdUIInfoHandler
{
public:
typedef UsdUfe::UsdUIInfoHandler Parent;
typedef std::shared_ptr<MayaUsdUIInfoHandler> Ptr;

MayaUsdUIInfoHandler();
~MayaUsdUIInfoHandler() override;

// Delete the copy/move constructors assignment operators.
MayaUsdUIInfoHandler(const MayaUsdUIInfoHandler&) = delete;
MayaUsdUIInfoHandler& operator=(const MayaUsdUIInfoHandler&) = delete;
MayaUsdUIInfoHandler(MayaUsdUIInfoHandler&&) = delete;
MayaUsdUIInfoHandler& operator=(MayaUsdUIInfoHandler&&) = delete;

//! Create a MayaUsdUIInfoHandler.
static MayaUsdUIInfoHandler::Ptr create();

UsdUfe::UsdUIInfoHandler::SupportedTypesMap getSupportedIconTypes() const override;

private:
void updateInvisibleColor();

// Note: the on-color-changed callback function is declared taking a void pointer
// to be compatible with MMessage callback API.
static void onColorChanged(void*);

MCallbackId fColorChangedCallbackId = 0;
}; // MayaUsdUIInfoHandler

} // namespace ufe
} // namespace MAYAUSD_NS_DEF

#endif // MAYAUSDUIINFOHANDLER_H
1 change: 1 addition & 0 deletions lib/usdUfe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ endif()
# -----------------------------------------------------------------------------
add_subdirectory(base)
add_subdirectory(python)
add_subdirectory(resources)
add_subdirectory(ufe)
add_subdirectory(undo)
add_subdirectory(utils)
1 change: 1 addition & 0 deletions lib/usdUfe/resources/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(icons)
49 changes: 49 additions & 0 deletions lib/usdUfe/resources/icons/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# ---------------------------------------------------------------------------------------------
# install
# ---------------------------------------------------------------------------------------------

# TreeView icons
set(TREEVIEW_ICONS
BlendShape
Camera
Capsule
CompArcBadge
CompArcBadgeV
Cone
Cube
Cylinder
Def
GeomSubset
LightFilter
LightPortal
Material
Mesh
NurbsPatch
PluginLight
PointInstancer
Points
Scope
Shader
SkelAnimation
Skeleton
SkelRoot
Sphere
UsdGeomCurves
UsdGeomXformable
UsdLuxBoundableLightBase
UsdLuxNonboundableLightBase
UsdTyped
Volume
)
foreach(ICON_BASE ${TREEVIEW_ICONS})
# The _100.png files need to be installed without the _100. This is the
# base icon name that is used. A DCC (such as Maya) will automatically
# choose the _150/_200 image if neeeded.
install(FILES "out_USD_${ICON_BASE}_100.png"
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/icons"
RENAME "out_USD_${ICON_BASE}.png"
)
install(FILES "out_USD_${ICON_BASE}_150.png" "out_USD_${ICON_BASE}_200.png"
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/icons"
Comment on lines +46 to +47
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Install most of the TreeView (Outliner) icons from UsdUfe. After discussing with Julien I kept the original naming "out_USD_XXX.png" (with the 150/200 versions).

)
endforeach()
2 changes: 2 additions & 0 deletions lib/usdUfe/ufe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ target_sources(${PROJECT_NAME}
UsdObject3dHandler.cpp
UsdRootChildHierarchy.cpp
UsdSceneItem.cpp
UsdUIInfoHandler.cpp
UsdUndoAddNewPrimCommand.cpp
UsdUndoAddPayloadCommand.cpp
UsdUndoAddRefOrPayloadCommand.cpp
Expand Down Expand Up @@ -58,6 +59,7 @@ set(HEADERS
UsdObject3dHandler.h
UsdRootChildHierarchy.h
UsdSceneItem.h
UsdUIInfoHandler.h
UsdUndoAddNewPrimCommand.h
UsdUndoAddPayloadCommand.h
UsdUndoAddRefOrPayloadCommand.h
Expand Down
3 changes: 3 additions & 0 deletions lib/usdUfe/ufe/Global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <usdUfe/ufe/UsdContextOpsHandler.h>
#include <usdUfe/ufe/UsdHierarchyHandler.h>
#include <usdUfe/ufe/UsdObject3dHandler.h>
#include <usdUfe/ufe/UsdUIInfoHandler.h>

#include <pxr/base/tf/diagnostic.h>

Expand Down Expand Up @@ -89,6 +90,8 @@ Ufe::Rtid initialize(
= handlers.object3dHandler ? handlers.object3dHandler : UsdObject3dHandler::create();
rtHandlers.contextOpsHandler
= handlers.contextOpsHandler ? handlers.contextOpsHandler : UsdContextOpsHandler::create();
rtHandlers.uiInfoHandler
= handlers.uiInfoHandler ? handlers.uiInfoHandler : UsdUIInfoHandler::create();
rtHandlers.cameraHandler
= handlers.cameraHandler ? handlers.cameraHandler : UsdCameraHandler::create();

Expand Down
5 changes: 3 additions & 2 deletions lib/usdUfe/ufe/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <ufe/hierarchyHandler.h>
#include <ufe/object3dHandler.h>
#include <ufe/rtid.h>
#include <ufe/uiInfoHandler.h>

#include <string>

Expand Down Expand Up @@ -65,8 +66,8 @@ struct USDUFE_PUBLIC Handlers
// Ufe::AttributesHandler::Ptr attributesHandler;
Ufe::Object3dHandler::Ptr object3dHandler;
Ufe::ContextOpsHandler::Ptr contextOpsHandler;
// Ufe::UIInfoHandler::Ptr uiInfoHandler;
Ufe::CameraHandler::Ptr cameraHandler;
Ufe::UIInfoHandler::Ptr uiInfoHandler;
Ufe::CameraHandler::Ptr cameraHandler;

#ifdef UFE_V3_FEATURES_AVAILABLE
// Ufe::PathMappingHandler::Ptr pathMappingHandler;
Expand Down
Loading