PythonOperation#
Fully qualified name: usd_optimize::PythonOperation
-
class PythonOperation : public usd_optimize::Operation#
Python Operation.
This operation is intended to be instantiated multiple times, with a configurable set of arguments and a python callback, as a generic base class for python plugins. It’s included in the core codebase as it should be easily accessible.
Public Functions
- explicit PythonOperation(
- const std::string &name,
- const std::string &displayName,
- const std::string &description,
- PyObject *pyObject,
Constructor.
-
~PythonOperation() override#
Destructor.
-
virtual std::string getDocumentation() const override#
Get the documentation string for this plugin.
-
virtual std::string getAuthor() const override#
Get the author of this plugin.
-
virtual UsdOptimizePluginVersion getVersion() const override#
Get the version of this plugin.
-
virtual bool getVisible() const override#
Returns whether or not this operation is visible.
- virtual OperationResult execute(
- ExecutionContext *context,
- const PXR_NS::JsObject &args,
Overrides the base execute method since we need to do some extra work to call the python function.
-
virtual std::string getCategory() const override#
Get the category for reporting.
-
std::string getName() const#
Get the name of this operation.
-
std::string getDisplayName() const#
Get the display name of this operation.
-
virtual std::string getDisplayGroup() const#
An optional UI grouping for the operation.
-
std::string getDescription() const#
Get the description of this plugin.
-
virtual bool getSupportsAnalysis() const#
Returns whether this operation supports analysis mode.
-
ExecutionContext *getContext() const#
Get the execution context.
-
PXR_NS::UsdStageWeakPtr getUsdStage() const#
Get the USD Stage that has been set on this operation.
-
template<typename T>
inline Argument &addArgument( - const std::string &name,
- const std::string &displayName,
- const std::string &displayType,
- const std::string &description,
- T &target,
Add an argument to this operation.
Adds an argument to the operation. A reference to the argument is returned so that any of the less common settings can be configured afterwards.
-
template<class ...Args>
inline Group &addGroup( - const std::string &name,
- Args&&... args,
Create a group of arguments.
Creates a series of arguments that should be grouped together e.g. in a UI. The group itself can have its own conditional expression to save having to specify it per argument.
Example usage:
addGroup("myGroup", addArgument(...), addArgument(...) ).setVisibleIf(...);
Groups will be returned from Operation::getArgs, and will be ordered prior to their children. You can use Argument::getIsGroup to check if an argument is a group.
-
virtual void setUserData(void *userData)#
Set custom user data for this operation.
This function can be used to let operations communicate with each other in a basic way. The data is operation specific.
- Parameters:
userData – Plugin-specific user data
Public Static Functions
-
static void log(int32_t level, const char *fmt, ...)#
Entry point for the USD_OPTIMIZE_LOG_X macros. Generally you don’t need to call this function directly.
- Parameters:
level – The level. See carb::logging::kLevelVerbose etc.
fmt – The format string
Protected Functions
-
virtual OperationResult executeImpl() override#
Unused since PythonOperation overrides
executedirectly.
-
Argument &addArgument(Argument *arg)#
Adds the given Argument to this Operation.
- Returns:
A reference to the added Argument
-
virtual OperationResult executeAnalysisImpl()#
Internal entry point for derived operations to perform analysis logic.