Rhino C++ API  8.13
Public Member Functions | List of all members
CRhRdkContentUndo Class Reference

#include <RhRdkContentUndo.h>

Inheritance diagram for CRhRdkContentUndo:
IRhRdkContentUndo

Public Member Functions

 CRhRdkContentUndo (const class CRhRdkDocument *pRdkDoc)
 
 CRhRdkContentUndo (const CRhinoDoc &doc)
 
RDK_DEPRECATED CRhRdkContentUndo (const wchar_t *wszDesc, INT_PTR reserved=0)
 
virtual ~CRhRdkContentUndo ()
 
virtual RDK_DEPRECATED bool AddContent (const CRhRdkContent &newContent)
 
virtual bool AddContent (const CRhRdkContent &newContent, const CRhRdkContent *pParent) override
 
virtual bool DeleteContent (const CRhRdkContentArray &aContent) override
 
virtual void DeleteThis (void) override
 
virtual bool DeleteTopLevelContent (const CRhRdkContentArrayNC &aContent) override
 
virtual void * EVF (const wchar_t *, void *) override
 
virtual bool ModifyContent (const CRhRdkContent &content) override
 
virtual_su bool PromoteContent (const CRhRdkContent &content)
 
virtual bool TweakContent (const CRhRdkContent &content, const wchar_t *wszParamName, const class CRhRdkVariant &vValueOld) override
 

Additional Inherited Members

- Protected Member Functions inherited from IRhRdkContentUndo
virtual ~IRhRdkContentUndo ()
 

Detailed Description

This is a stack object that makes it easy for clients to implement content undo. If you use the CRhRdkContentField object for storing your content's variables, you may not need to use this class since the field system takes care of parameter undo automatically. Use this class for handling parameter undo for data that is not stored in fields, or for handling custom content adds and deletes.

See also
CRhRdkContentField
Note
For this to work, your UI is responsible for starting an undo record.
See also
CRhRdkUndoableEvent
CRhRdkNewUndoableEvent
uuidData_RdkUndo

Constructor & Destructor Documentation

◆ CRhRdkContentUndo() [1/3]

RDK_DEPRECATED CRhRdkContentUndo::CRhRdkContentUndo ( const wchar_t *  wszDesc,
INT_PTR  reserved = 0 
)

This constructor is deprecated in favor of the one below.

Parameters
wszDescis obsolete and not used. You must make sure an undo record is active at the time this object is created.
See also
CRhRdkUndoableEvent
uuidData_RdkUndo

◆ CRhRdkContentUndo() [2/3]

CRhRdkContentUndo::CRhRdkContentUndo ( const CRhinoDoc doc)

Use this constructor if you have a reference to a Rhino document.

Note
You must make sure an undo record is active at the time this object is created or it will have no effect.
See also
CRhRdkUndoableEvent
uuidData_RdkUndo

◆ CRhRdkContentUndo() [3/3]

CRhRdkContentUndo::CRhRdkContentUndo ( const class CRhRdkDocument pRdkDoc)

Use this constructor if you have a pointer to an RDK document. The pointer can be null. Undo will only be recorded if the RDK document is not null and is associated with a Rhino document.

Note
You must make sure an undo record is active at the time this object is created or it will have no effect.
See also
CRhRdkUndoableEvent
uuidData_RdkUndo

◆ ~CRhRdkContentUndo()

virtual CRhRdkContentUndo::~CRhRdkContentUndo ( )
virtual

Member Function Documentation

◆ AddContent() [1/2]

virtual RDK_DEPRECATED bool CRhRdkContentUndo::AddContent ( const CRhRdkContent newContent)
virtual
Note
This method is obsolete because it does not support redo. It has only been retained for backward compatibility. Please call the other AddContent() method instead.

◆ AddContent() [2/2]

virtual bool CRhRdkContentUndo::AddContent ( const CRhRdkContent newContent,
const CRhRdkContent pParent 
)
overridevirtual

Call this after creating a new content but before adding it to the document.

Parameters
newContentis the new content being added.
pParentis a pointer to the content that will become the parent of the new content, or null if the new content is being added at the top level (i.e., not a child).
Returns
true if successful, else false.

Implements IRhRdkContentUndo.

◆ DeleteContent()

virtual bool CRhRdkContentUndo::DeleteContent ( const CRhRdkContentArray aContent)
overridevirtual

Call this before deleting one or more contents. This copies the content hierarchies into the undo object and is therefore somewhat inefficient. If all the contents are top-level, it is better to call DeleteTopLevelContent() instead.

Parameters
aContentis an array of pointers to the contents being deleted.

Implements IRhRdkContentUndo.

◆ DeleteThis()

virtual void CRhRdkContentUndo::DeleteThis ( void  )
inlineoverridevirtual

This method is implemented as

delete this;

Implements IRhRdkContentUndo.

◆ DeleteTopLevelContent()

virtual bool CRhRdkContentUndo::DeleteTopLevelContent ( const CRhRdkContentArrayNC aContent)
overridevirtual

Call this before 'deleting' one or more top-level contents. This requires the caller to merely detach the contents from the document and pass ownership of them to this object. It eliminates the need to copy the contents and the need to actually delete them, thus saving time and memory. Although the contents are not actually deleted, the user still perceives them as deleted because they disappear from the UI when detached.

Parameters
aContentis an array of pointers to the contents being 'deleted'. If any one of these contents is a child, the function will fail.

Implements IRhRdkContentUndo.

◆ EVF()

virtual void* CRhRdkContentUndo::EVF ( const wchar_t *  ,
void *   
)
overridevirtual

Emergency virtual function for future expansion.

Implements IRhRdkContentUndo.

◆ ModifyContent()

virtual bool CRhRdkContentUndo::ModifyContent ( const CRhRdkContent content)
overridevirtual

Call this before modifying a content in a significant way, for example changing a child.

Note
If you are just changing a simple parameter such as color, you should call TweakContent() instead.
Parameters
contentis the content being modified.

Implements IRhRdkContentUndo.

◆ PromoteContent()

virtual_su bool CRhRdkContentUndo::PromoteContent ( const CRhRdkContent content)

Call this before promoting a single content from reference to non-reference.

Parameters
contentis the content being promoted.

◆ TweakContent()

virtual bool CRhRdkContentUndo::TweakContent ( const CRhRdkContent content,
const wchar_t *  wszParamName,
const class CRhRdkVariant vValueOld 
)
overridevirtual

Call this before tweaking a single content parameter. It is more efficient than calling ModifyContent() because it only saves and restores the single changed parameter instead of the whole content hierarchy.

Parameters
contentis the content being tweaked.
wszParamNameis the name of the parameter being tweaked.
vValueOldis the value of the parameter before the tweak is applied.

Implements IRhRdkContentUndo.