Viewer Delegate Components
- group FnViewerDelegateComponent
Typedefs
-
typedef std::shared_ptr<ViewerDelegateComponentWrapper> ViewerDelegateComponentWrapperPtr
-
class ViewerDelegateComponentPluginBase
- #include <FnViewerDelegateComponent.h>
Extends the functionality of an existing ViewerDelegate.
A ViewerDelegateComponent allows to extend the support for more location types or attribute conventions that are not supported by the ViewerDelegate. Together with the ViewportLayer plugin type, an already compiled Viewer can be extended. This can also be used to modularize the features of a ViewerDelegate. For example each location type can have its own ViewerDelegateComponent, which can be added/removed to the Viewer at runtime.
Whenever a ViewerDelegateComponent has to access some private data that is kept in the ViewerDelegate the method ViewerDelegate::getPrivateData() can be used to access that data. In this case the compiler used to build the ViewerDelegate and the ViewerDelegateComponent have to be the same.
A ViewerDelegateComponent ‘locationEvent’ callback function can return true in order to inform other ViewerDelegateComponents and the ViewerDelegate that it is handling the location. This may allow existing functionality in the ViewerDelegate to be removed/ignored. For example, if the ViewerDelegate has 2 ViewerDelegateComponent (A and B) and a new one (C) is added, then if C::locationEvent() returns true, then the locationEvent() callback of A, B, and the ViewerDelegate will be called with locationHandled=true.
ViewerDelegateComponent is the class that plugins should extend and implement.
ViewerDelegateComponentWrapper is the class that allows other plugin types to access the ViewerDelegateComponent plugin.
ViewerDelegateComponentPluginBase is the base class that provides the common methods between ViewerDelegateComponent and ViewerDelegateComponentWrapper.
Subclassed by Foundry::Katana::ViewerAPI::ViewerDelegateComponent, Foundry::Katana::ViewerAPI::ViewerDelegateComponentWrapper
Public Functions
-
ViewerDelegateComponentPluginBase()
Constructor.
-
virtual ~ViewerDelegateComponentPluginBase()
Destructor.
-
ViewerDelegateWrapperPtr getViewerDelegate()
Returns the viewer delegate that this component is associated with.
- Returns:
A pointer to the ViewerDelegate.
-
FnAttribute::GroupAttribute getAttributes(const std::string &locationPath)
Gets cooked attributes for a location.
Gets the cached cooked attributes for the location. Returns an invalid group attribute if the location hasn’t been cooked.
During the manipulation of an attribute by a Manipulator, the last value set by it will be returned instead of the cached cooked attribute. This allows faster interactive representation of the scene graph during the manipulation, since the cooking might not be fast enough to provide an interactive speed.
- Parameters:
locationPath – The location path.
- Returns:
The attributes of the location.
-
ViewerDelegateComponentPluginBase()
-
class ViewerDelegateComponent : public Foundry::Katana::ViewerAPI::ViewerDelegateComponentPluginBase
- #include <FnViewerDelegateComponent.h>
The ViewerDelegateComponent class to be extended by plugins.
Subclassed by BallComponent, Foundry::Katana::ViewerUtils::FnUsdBaseLocatorVDC, IgnoreComponent, LoggingComponent
Public Functions
-
ViewerDelegateComponent()
-
virtual ~ViewerDelegateComponent()
-
virtual void setup() = 0
Initializes the ViewportDelegateComponent’s resources.
-
virtual void cleanup() = 0
Cleans up the ViewportDelegateComponent’s resources.
-
virtual bool locationEvent(const ViewerLocationEvent &event, bool locationHandled) = 0
Notification of scene graph location state changes.
- Parameters:
event – Struct containing location event information (see “FnViewerLocationEvent.h” for details).
locationHandled – True if an already processed (later added) ViewerDelegateComponent has stated that it is handling this location by returning true. In this case, the ViewerDelegateComponent should not draw its own representation.
- Returns:
true if the other ViewerDelegateComponents added to the ViewerDelegate before this one should receive locationHandled=true, false otherwise.
-
inline virtual bool usdPrimEvent(const ViewerUsdPrimEvent &event, const bool handled)
Notification of USD Prim state changes.
- Parameters:
event – Struct containing the event information (i.e. a reference to the USD Prim, and whether it has been added or removed, or updated).
handled –
true
if another ViewerDelegateComponent with higher priority has stated, on processing this event, that it is handling the prim. In this case, this ViewerDelegateComponent should not draw its own representation.
- Returns:
true
if this ViewerDelegateComponent is handling the prim, making other ViewerDelegateComponents with lower priority receive this event withhandled
set totrue
.
-
virtual void locationsSelected(const std::vector<std::string> &locationPaths) = 0
Called when the location selection changes in Katana.
- Parameters:
locationPaths – The selected location paths.
-
inline virtual void usdPrimsSelected(const std::vector<std::string> &primPaths)
Called when the USD Prim selection changes in Katana.
- Parameters:
primPaths – The selected USD Prim paths.
-
inline virtual bool isProcessing() const
Queries the processing of the Viewer Delegate Component plug-in.
- Returns:
true if the plug-in is processing anything that may result in a change to the Viewer.
-
inline virtual void *getPrivateData(void *inputData)
Returns some arbitrary data.
This can be used by other plugins to access some data that is specific to this object after it is compiled, allowing built-in parts of existing Viewers to be extendable by other plugins like ViewerDelegateComponents, Viewports and ViewportLayers.
This function should be called by other plugins after getting a ManipulatorWrapperPtr and converting it into a concrete instance via ManipulatorWrapper::getPluginInstance(). These other plugins will have to be built with the same compiler and using the same compiler flags as the ViewerDelegate so that this data can be cast and used without running into C++ name mangling issues.
- Parameters:
inputData – A pointer to some input data that can be used to produce the returned data.
- Returns:
The arbitrary private data. A void pointer that can be cast into specific object types by other plugins.
-
inline virtual void setOption(OptionIdGenerator::value_type optionId, FnAttribute::Attribute attr)
Sets a generic option.
Optional. Reacts to a generic option being set from Python or called directly by other C++ Viewer plugin classes. This can be used as a message passing mechanism from the outside into the ViewerDelegateComponent.
- Parameters:
optionId – The ID of the option created from OptionIdGenerator or manually defined by users.
attr – Attribute with the value being set.
-
virtual FnAttribute::Attribute getOption(OptionIdGenerator::value_type optionId)
Gets the value of a generic option.
Optional. Returns the value of a generic option being requested from Python or from other C++ Viewer plugin classes.
- Parameters:
optionId – The ID of the option created from OptionIdGenerator or manually defined by users.
- Returns:
Attribute with the value of the option.
-
void setOption(const std::string &name, FnAttribute::Attribute attr)
Sets a generic option by generating an option ID from the passed name.
This generates an Option ID from the passed string and passes it to setOption(OptionIdGenerator::value_type optionId,FnAttribute::Attribute attr). Since the ID is generated on every call, it is more efficient to generate the ID once, and store it for future use.
- Parameters:
name – The name of the option whose value to set.
attr – Attribute with the value to set for the option.
-
FnAttribute::Attribute getOption(const std::string &name)
Gets a generic option by generating an option ID from the passed name.
This generates an Option ID from the passed string and passes it to getOption(OptionIdGenerator::value_type optionId). Since the ID is generated on every call, it is more efficient to generate the ID once, and store it for future use.
- Parameters:
name – The name of the option whose value to retrieve.
- Returns:
The value of the option with the given name.
-
virtual FnAttribute::DoubleAttribute getBounds(const std::string &locationPath)
Gets the bounds of the given location.
- Parameters:
locationPath – The location path.
- Returns:
The bounds of the location (or an invalid attribute if not found).
-
virtual FnAttribute::DoubleAttribute computeExtent(const std::string &locationPath)
Calculates the extent of the given location.
It calculates the extent of the location based on its geometry.
- Parameters:
locationPath – The location path.
- Returns:
The extent of the location (or an invalid attribute if no extent was computed).
Public Static Functions
-
static inline void flush()
Flush plugin Caches.
Allows to discard any cache for this plugin when a Flush Caches event occurs.
-
ViewerDelegateComponent()
-
class ViewerDelegateComponentWrapper : public Foundry::Katana::ViewerAPI::ViewerDelegateComponentPluginBase
- #include <FnViewerDelegateComponent.h>
The ViewerDelegateComponent class accessed by other plugins.
Public Functions
-
ViewerDelegateComponentWrapper(FnPluginHost *host, FnViewerDelegateComponentHostHandle hostHandle, FnViewerDelegateComponentPluginHandle pluginHandle, FnViewerDelegateComponentPluginSuite_v2 *pluginSuite)
-
~ViewerDelegateComponentWrapper()
-
template<class T>
inline T *getPluginInstance() Gets a pointer to the real plugin instance.
WARNING: This function purposely breaks the compiler agnostic pattern of the Katana plugin API, so it needs to be used with care. This performs a dynamic cast to the real type so the implications of what that means in different circumstances should be understood. If the caller and plugin instance are not contained in the same shared library the RTTI check may fail.
This function allows a plugin wrapper to return the actual plugin class. The plugin is returned as a pointer to a child class of ViewerDelegateComponent that is a registerd plugin. The type of that child class needs to be specified in the template, so that it can be properly cast. If the specified type doesn’t match the plugin type then NULL is returned.
-
void setOption(OptionIdGenerator::value_type optionId, FnAttribute::Attribute attr)
Sets a generic option.
-
FnAttribute::Attribute getOption(OptionIdGenerator::value_type optionId)
Gets a generic option.
-
void setOption(const std::string &name, FnAttribute::Attribute attr)
Sets a generic option.
-
FnAttribute::Attribute getOption(const std::string &name)
Gets a generic option.
-
FnAttribute::DoubleAttribute getBounds(const std::string &location)
Gets the bounds of the given location.
-
FnAttribute::DoubleAttribute computeExtent(const std::string &location)
Calculates the extent of the given location.
-
ViewerDelegateComponentWrapper(FnPluginHost *host, FnViewerDelegateComponentHostHandle hostHandle, FnViewerDelegateComponentPluginHandle pluginHandle, FnViewerDelegateComponentPluginSuite_v2 *pluginSuite)
-
typedef std::shared_ptr<ViewerDelegateComponentWrapper> ViewerDelegateComponentWrapperPtr