All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
UsdEditContext Class Reference

A utility class to temporarily modify a stage's current EditTarget during an execution scope. More...

#include <editContext.h>

Public Member Functions

USD_API UsdEditContext (const UsdStagePtr &stage)
 Construct without modifying stage's current EditTarget.
 
USD_API UsdEditContext (const UsdStagePtr &stage, const UsdEditTarget &editTarget)
 Construct and save stage's current EditTarget to restore on destruction, then invoke stage->SetEditTarget(editTarget).
 
USD_API UsdEditContext (const std::pair< UsdStagePtr, UsdEditTarget > &stageTarget)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This ctor is handy to construct an edit context from the return value of another function (Cannot return a UsdEditContext since it needs to be noncopyable).
 
USD_API ~UsdEditContext ()
 Restore the stage's original EditTarget if this context's stage is valid.
 

Detailed Description

A utility class to temporarily modify a stage's current EditTarget during an execution scope.

This is an "RAII"-like object meant to be used as an automatic local variable. Upon construction, it sets a given stage's EditTarget, and upon destruction it restores the stage's EditTarget to what it was previously.

Example usage, temporarily overriding a stage's EditTarget to direct an edit to the stage's session layer. When the ctx object expires, it restores the stage's EditTarget to whatever it was previously.

void SetVisState(const UsdPrim &prim, bool vis) {
prim.GetStage()->GetSessionLayer());
prim.GetAttribute("visible").Set(vis);
}
bool Set(const T &value, UsdTimeCode time=UsdTimeCode::Default()) const
Set the value of this attribute in the current UsdEditTarget to value at UsdTimeCode time,...
Definition: attribute.h:461
A utility class to temporarily modify a stage's current EditTarget during an execution scope.
Definition: editContext.h:51
USD_API UsdStageWeakPtr GetStage() const
Return the stage that owns the object, and to whose state and lifetime this object's validity is tied...
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:117
USD_API UsdAttribute GetAttribute(const TfToken &attrName) const
Return a UsdAttribute with the name attrName.

Threading Note

When one thread is mutating a UsdStage, it is unsafe for any other thread to either query or mutate it. Using this class with a stage in such a way that it modifies the stage's EditTarget constitutes a mutation.

Definition at line 50 of file editContext.h.

Constructor & Destructor Documentation

◆ UsdEditContext() [1/3]

USD_API UsdEditContext ( const UsdStagePtr &  stage)
explicit

Construct without modifying stage's current EditTarget.

Save stage's current EditTarget to restore on destruction.

If stage is invalid, a coding error will be issued by the constructor, and this class takes no action.

◆ UsdEditContext() [2/3]

USD_API UsdEditContext ( const UsdStagePtr &  stage,
const UsdEditTarget editTarget 
)

Construct and save stage's current EditTarget to restore on destruction, then invoke stage->SetEditTarget(editTarget).

If stage is invalid, a coding error will be issued by the constructor, and this class takes no action.

If editTarget is invalid, a coding error will be issued by the stage, and its EditTarget will not be modified.

◆ UsdEditContext() [3/3]

USD_API UsdEditContext ( const std::pair< UsdStagePtr, UsdEditTarget > &  stageTarget)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This ctor is handy to construct an edit context from the return value of another function (Cannot return a UsdEditContext since it needs to be noncopyable).

If stage is invalid, a coding error will be issued by the constructor, and this class takes no action.

If editTarget is invalid, a coding error will be issued by the stage, and its EditTarget will not be modified.

◆ ~UsdEditContext()

USD_API ~UsdEditContext ( )

Restore the stage's original EditTarget if this context's stage is valid.

Otherwise do nothing.


The documentation for this class was generated from the following file: