Rhino C++ API  9.0
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 *, INT_PTR reserved=0)
 
virtual ~CRhRdkContentUndo ()
 
virtual RDK_DEPRECATED bool AddContent (const CRhRdkContent &)
 
virtual bool AddContent (const CRhRdkContent &new_content, const CRhRdkContent *parent) override
 
virtual bool DeleteContent (const CRhRdkContentArray &contents) override
 
virtual void DeleteThis (void) override
 
virtual bool DeleteTopLevelContent (const CRhRdkContentArrayNC &contents) override
 
virtual void * EVF (const wchar_t *, void *) override
 
bool HasContent (const CRhRdkContent &c) const
 
virtual bool ModifyContent (const CRhRdkContent &c) override
 
virtual_su bool PromoteContent (const CRhRdkContent &c)
 
virtual bool TweakContent (const CRhRdkContent &c, const wchar_t *param_name, const class CRhRdkVariant &value_old) 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.

Note
This class can be instantiated more than once (in nested or recursive functions) and will still work as if only one was instantiated. This removes the need to worry about an instance already existing at a level above.
For this to work outside of a command, you will need to start an undo record in the relevant document.
See also
CRhRdkContentField
CRhRdkUndoableEvent

Constructor & Destructor Documentation

◆ CRhRdkContentUndo() [1/3]

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

This constructor is deprecated in favor of the one below.

◆ 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 in the given document at the time this object is created or it will have no effect.
See also
CRhRdkUndoableEvent

◆ 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 in the given document at the time this object is created or it will have no effect.
See also
CRhRdkUndoableEvent

◆ ~CRhRdkContentUndo()

virtual CRhRdkContentUndo::~CRhRdkContentUndo ( )
virtual

Member Function Documentation

◆ AddContent() [1/2]

virtual RDK_DEPRECATED bool CRhRdkContentUndo::AddContent ( const CRhRdkContent )
virtual

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 new_content,
const CRhRdkContent parent 
)
overridevirtual

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

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

Implements IRhRdkContentUndo.

◆ DeleteContent()

virtual bool CRhRdkContentUndo::DeleteContent ( const CRhRdkContentArray contents)
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 contents)
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.

◆ HasContent()

bool CRhRdkContentUndo::HasContent ( const CRhRdkContent c) const
Returns
true if the given content has already been added to this content undo.

◆ ModifyContent()

virtual bool CRhRdkContentUndo::ModifyContent ( const CRhRdkContent c)
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 c)

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 c,
const wchar_t *  param_name,
const class CRhRdkVariant value_old 
)
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.