Skip to content

Commit

Permalink
Merge pull request #2766 from Autodesk/gamaj/MAYA-126625/connection_r…
Browse files Browse the repository at this point in the history
…ework

MAYA-126625 Connections now handled internally
  • Loading branch information
seando-adsk authored Dec 6, 2022
2 parents ce8c614 + 9aa3f72 commit 9242726
Show file tree
Hide file tree
Showing 6 changed files with 747 additions and 2 deletions.
13 changes: 13 additions & 0 deletions lib/mayaUsd/ufe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ if(CMAKE_UFE_V4_FEATURES_AVAILABLE)
UsdTransform3dRead.cpp
)
endif()

if (${UFE_PREVIEW_VERSION_NUM} GREATER_EQUAL 4043)
target_sources(${PROJECT_NAME}
PRIVATE
UsdUndoConnectionCommands.cpp
)
endif()
endif()

if(PXR_VERSION GREATER_EQUAL 2108)
Expand Down Expand Up @@ -352,6 +359,12 @@ if(CMAKE_UFE_V4_FEATURES_AVAILABLE)
UsdTransform3dRead.h
)
endif()

if (${UFE_PREVIEW_VERSION_NUM} GREATER_EQUAL 4043)
list(APPEND HEADERS
UsdUndoConnectionCommands.h
)
endif()
endif()

if(PXR_VERSION GREATER_EQUAL 2108)
Expand Down
35 changes: 35 additions & 0 deletions lib/mayaUsd/ufe/UsdConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include <mayaUsd/ufe/UsdConnections.h>
#include <mayaUsd/ufe/UsdHierarchyHandler.h>
#include <mayaUsd/ufe/UsdSceneItem.h>
#if (UFE_PREVIEW_VERSION_NUM >= 4043)
#include <mayaUsd/ufe/UsdUndoConnectionCommands.h>
#endif

#include <pxr/base/tf/diagnostic.h>
#include <pxr/usd/sdr/registry.h>
Expand All @@ -32,6 +35,12 @@ PXR_NAMESPACE_USING_DIRECTIVE
namespace MAYAUSD_NS_DEF {
namespace ufe {

#if (UFE_PREVIEW_VERSION_NUM < 4043)

//
// For UFE 0.4.43 the connection/disconnection code is moved to UsdUndoConnectionCommands.cpp
//

namespace {

UsdAttribute* usdAttrFromUfeAttr(const Ufe::Attribute::Ptr& attr)
Expand Down Expand Up @@ -118,6 +127,8 @@ void _SendStrongConnectionChangeNotification(const UsdPrim& usdPrim)

} // namespace

#endif

UsdConnectionHandler::UsdConnectionHandler()
: Ufe::ConnectionHandler()
{
Expand All @@ -135,6 +146,28 @@ Ufe::Connections::Ptr UsdConnectionHandler::sourceConnections(const Ufe::SceneIt
return UsdConnections::create(item);
}

#if (UFE_PREVIEW_VERSION_NUM >= 4043)

Ufe::ConnectionResultUndoableCommand::Ptr UsdConnectionHandler::createConnectionCmd(
const Ufe::Attribute::Ptr& srcAttr,
const Ufe::Attribute::Ptr& dstAttr) const
{
return UsdUndoCreateConnectionCommand::create(srcAttr, dstAttr);
}

Ufe::UndoableCommand::Ptr UsdConnectionHandler::deleteConnectionCmd(
const Ufe::Attribute::Ptr& srcAttr,
const Ufe::Attribute::Ptr& dstAttr) const
{
return UsdUndoDeleteConnectionCommand::create(srcAttr, dstAttr);
}

#else

//
// For UFE 0.4.43 the connection/disconnection code is moved to UsdUndoConnectionCommands.cpp
//

bool UsdConnectionHandler::createConnection(
const Ufe::Attribute::Ptr& srcAttr,
const Ufe::Attribute::Ptr& dstAttr) const
Expand Down Expand Up @@ -269,5 +302,7 @@ bool UsdConnectionHandler::deleteConnection(
return retVal;
}

#endif

} // namespace ufe
} // namespace MAYAUSD_NS_DEF
20 changes: 18 additions & 2 deletions lib/mayaUsd/ufe/UsdConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include <ufe/connectionHandler.h>

#include <memory>

namespace MAYAUSD_NS_DEF {
namespace ufe {

Expand All @@ -44,13 +46,27 @@ class MAYAUSD_CORE_PUBLIC UsdConnectionHandler : public Ufe::ConnectionHandler

Ufe::Connections::Ptr sourceConnections(const Ufe::SceneItem::Ptr& item) const override;

#if (UFE_PREVIEW_VERSION_NUM >= 4043)
std::shared_ptr<Ufe::ConnectionResultUndoableCommand> createConnectionCmd(
const Ufe::Attribute::Ptr& srcAttr,
const Ufe::Attribute::Ptr& dstAttr) const override;

std::shared_ptr<Ufe::UndoableCommand> deleteConnectionCmd(
const Ufe::Attribute::Ptr& srcAttr,
const Ufe::Attribute::Ptr& dstAttr) const override;

private:
Ufe::Connection
createConnection(const Ufe::Attribute::Ptr& srcAttr, const Ufe::Attribute::Ptr& dstAttr) const;
void
deleteConnection(const Ufe::Attribute::Ptr& srcAttr, const Ufe::Attribute::Ptr& dstAttr) const;
#else
protected:
bool createConnection(const Ufe::Attribute::Ptr& srcAttr, const Ufe::Attribute::Ptr& dstAttr)
const override;
bool deleteConnection(const Ufe::Attribute::Ptr& srcAttr, const Ufe::Attribute::Ptr& dstAttr)
const override;

#endif
}; // UsdConnectionHandler

} // namespace ufe
} // namespace MAYAUSD_NS_DEF
Loading

0 comments on commit 9242726

Please sign in to comment.