The ViewContext object serves 2 functions for Custom Displays:
void MyCustomDisplay_Init (XSI::CRef in_pViewCtx) { // cast the CRef into a ViewContext object XSI::ViewContext l_vViewContext = in_pViewCtx; // make sure it is valid assert ( l_vViewContext.IsValid() ); // Get the string-based metadata associated with this view context, // which was specified via SetAttributeValue() // XSI::CString l_szMetadata = l_vViewContext.GetMetadata(); // Get the parent window handle. We will use this to // create our own child window. HWND l_hParent = (HWND)l_vViewContext.GetParentWindowHandle(); // Create our window as a child of the XSI parent window HWND l_hMyWindow = CreateDialog( MyDllInstance, MAKEINTRESOURCE(IDD_MYCUSTOMWINDOW), l_hParent, (DLGPROC)MyWindowProc); } void MyCustomDisplay_Notify ( XSI::CRef in_pViewContext ) { // cast the CRef into a ViewContext object XSI::ViewContext l_vViewContext = in_pViewCtx; // make sure it is valid assert ( l_vViewContext.IsValid() ); XSI::siEventID in_eNotifcation; void* in_pData; l_vViewContext.GetNotificationData ( in_eNotifcation, &in_pData ); switch ( in_eNotifcation ) { case siOnSelectionChange: { XSI::CSelectionChangeNotification* l_pSelection = (XSI::CSelectionChangeNotification*)in_pData; XSI::CString l_szMessage; l_szMessage = L"XSI_SELECTION_CHANGED_CV"; l_szMessage += L" [ "; // // Build a string of all objects that are in the selection list // for (INT c=0;c<l_pSelection->GetSelectionList().GetCount();c++) { XSI::CRef& l_pCRef = l_pSelection->GetSelectionList().GetItem(c); XSI::SIObject mySIObject ( l_pCRef ); XSI::CString Name = mySIObject.GetFullName(); if ( c != 0 ) l_szMessage += L","; l_szMessage += Name;; } l_szMessage += L" ]"; // // And print it // char *l_szMessChar = new char [ l_szMessage.Length() + 1 ]; W2AHelper ( l_szMessChar, l_szMessage.GetWideString() ); OutputDebugString ( l_szMessChar ); delete [] l_szMessChar; break; } case siOnTimeChange: { XSI::CTimeChangeNotification* l_pTimeChange = (XSI::CTimeChangeNotification*)in_pData; XSI::CString l_szMessage; l_szMessage = L"XSI_TIME_CHANGE_CV"; char *l_szMessChar = new char [ l_szMessage.Length() + 1 ]; DSW2AHelper ( l_szMessChar, l_szMessage.GetWideString() ); OutputDebugString ( l_szMessChar ); delete [] l_szMessChar; break; } case siOnValueChange: { XSI::CString l_szMessage; l_szMessage = L"XSI_SET_VALUE_CV "; XSI::CValueChangeNotification* l_pData = (XSI::CValueChangeNotification*) in_pData; XSI::CString l_csCIDName = l_pData->GetOwner().GetClassIDName(); l_szMessage += l_csCIDName; l_szMessage += L" [ "; l_szMessage += l_pData->GetComponentName(); l_szMessage += L" ]"; char *l_szMessChar = new char [ l_szMessage.Length() + 1 ]; DSW2AHelper ( l_szMessChar, l_szMessage.GetWideString() ); OutputDebugString ( l_szMessChar ); delete [] l_szMessChar; break; } } }
#include <xsi_viewcontext.h>
Public Member Functions | |
ViewContext () | |
~ViewContext () | |
ViewContext (const CRef &in_ref) | |
ViewContext (const ViewContext &in_obj) | |
bool | IsA (siClassID in_ClassID) const |
siClassID | GetClassID () const |
ViewContext & | operator= (const ViewContext &in_obj) |
ViewContext & | operator= (const CRef &in_ref) |
CString | GetMetadata () const |
CValue | GetUserData () |
CStatus | PutUserData (const CValue &in_val) |
void * | GetParentWindowHandle () |
View | GetView () |
CStatus | GetNotificationData (siEventID &out_eEventID, void **out_pData) |
CStatus | SetFlags (LONG in_lFlags) |
CStatus | SetXWindowTopLevel (void *in_pHandle) |
void * | GetTopLevelWidget () |
ViewContext | ( | ) |
Default constructor.
~ViewContext | ( | ) |
Default destructor.
ViewContext | ( | const CRef & | in_ref | ) |
Constructor.
in_ref | constant reference object. |
ViewContext | ( | const ViewContext & | in_obj | ) |
Copy constructor.
in_obj | constant class object. |
bool IsA | ( | siClassID | in_ClassID | ) | const [virtual] |
Returns true if a given class type is compatible with this API class.
in_ClassID | class type. |
Reimplemented from CBase.
siClassID GetClassID | ( | ) | const [virtual] |
ViewContext& operator= | ( | const ViewContext & | in_obj | ) |
Creates an object from another object.
in_obj | constant class object. |
ViewContext& operator= | ( | const CRef & | in_ref | ) |
Creates an object from a reference object. The newly created object is set to empty if the input reference object is not compatible.
in_ref | constant class object. |
CString GetMetadata | ( | ) | const |
Returns the current view Metadata associated with the Context. Metadata is string data that can be used during the early initialization of a Custom Display Host. It also provides another way to store more data should UserData already be filled with a value. The "metadata" view attribute can be set via SetAttributeValue() on the view before the "targetcontent" view attribute is set, allowing the Custom Display Host to recognize the "metadata" view attribute early on.
Allows you to store a CValue inside the context object. This is called User Data because Softimage does not care about the content or meaning of the data. This information is not persisted. A common use for this feature is to store a pointer to a newly allocated C++ object during an Init
callback, and then to use Context::GetUserData to retrieve the pointer when other callbacks are made. (In this scenario the object should be destroyed in the cb_Plugin_Term Term callback).
in_val | user data to be set for the operator instance. |
void* GetParentWindowHandle | ( | ) |
Returns the platform-specific parent window handle. For Windows, this must be cast to a HWND.
View GetView | ( | ) |
Returns the data associated with a notification event
out_eEventID | the event that was fired |
out_pData | the associated data |
CStatus SetFlags | ( | LONG | in_lFlags | ) |
CStatus SetXWindowTopLevel | ( | void * | in_pHandle | ) |
Specifies the top level X window for the Custom Display.
in_pHandle | The pointer to the X Window handle |
void* GetTopLevelWidget | ( | ) |
Returns the top level widget from Softimage. This is necessary in order to create your custom display as a child of this widget.