Commit f3a3afc4 authored by Sebastien Jourdain's avatar Sebastien Jourdain

Fix Undo/Redo implicit function recover

parent 0ad243c9
......@@ -103,7 +103,7 @@ void pqHelperProxyRegisterUndoElement::RegisterHelperProxies(pqProxy* proxy)
}
//-----------------------------------------------------------------------------
int pqHelperProxyRegisterUndoElement::Redo()
int pqHelperProxyRegisterUndoElement::DoTheJob()
{
if (!this->Session)
{
......
......@@ -39,7 +39,8 @@ class pqProxy;
/// This is a special undo element that gets added after a proxy
/// (referred to as "source" proxy) and all its
/// helpers have been registered.
/// helpers have been registered.
/// AND before it's proxy and all its helpers have been UNregistered.
/// On undo, this element does nothing since the creation of
/// helper proxies will automatically be undone before the undo for creation
/// of the "source" proxy. However, on redo,
......@@ -54,15 +55,18 @@ public:
static pqHelperProxyRegisterUndoElement* New();
vtkTypeMacro(pqHelperProxyRegisterUndoElement, vtkSMUndoElement);
void PrintSelf(ostream& os, vtkIndent indent);
void SetOperationTypeToUndo() { this->ForUndo = true; }
void SetOperationTypeToRedo() { this->ForUndo = false; }
/// Description:
/// Undo the operation encapsulated by this element.
virtual int Undo() {return 1; }
/// We make the pqProxy aware of its helper proxies.
virtual int Undo() { return this->ForUndo ? this->DoTheJob() : 1; }
/// Description:
/// Redo the operation encaspsulated by this element.
/// We make the pqProxy aware of its helper proxies.
virtual int Redo();
virtual int Redo() { return this->ForUndo ? 1 : this->DoTheJob(); }
/// Description:
/// Creates the element to setup helper proxies for the proxy.
......@@ -72,6 +76,9 @@ protected:
pqHelperProxyRegisterUndoElement();
~pqHelperProxyRegisterUndoElement();
virtual int DoTheJob();
bool ForUndo;
private:
pqHelperProxyRegisterUndoElement(const pqHelperProxyRegisterUndoElement&); // Not implemented.
void operator=(const pqHelperProxyRegisterUndoElement&); // Not implemented.
......
......@@ -383,11 +383,12 @@ void pqPipelineSource::setDefaultPropertyValues()
this->createAnimationHelpersIfNeeded();
// This is sort-of-a-hack to ensure that when this operation is undo, all the
// This is sort-of-a-hack to ensure that when this operation is redo, all the
// helper proxies are discovered correctly. This needs to happen only after
// all helper proxies have been created.
pqHelperProxyRegisterUndoElement* elem =
pqHelperProxyRegisterUndoElement::New();
elem->SetOperationTypeToRedo(); // Redo creation
elem->RegisterHelperProxies(this);
ADD_UNDO_ELEM(elem);
elem->Delete();
......
......@@ -40,6 +40,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtkSMProxyIterator.h"
#include "vtkSMProxyManager.h"
#include "pqHelperProxyRegisterUndoElement.h"
#include "pqUndoStack.h"
#include <QMap>
#include <QList>
#include <QtDebug>
......@@ -146,6 +149,16 @@ void pqProxy::updateHelperProxies() const
//-----------------------------------------------------------------------------
void pqProxy::clearHelperProxies()
{
// This is sort-of-a-hack to ensure that when this operation (delete)
// is undo, all the helper proxies are discovered correctly. This needs to
// happen only when all helper proxies are still around.
pqHelperProxyRegisterUndoElement* elem =
pqHelperProxyRegisterUndoElement::New();
elem->SetOperationTypeToUndo(); // Undo deletion
elem->RegisterHelperProxies(this);
ADD_UNDO_ELEM(elem);
elem->Delete();
vtkSMProxyManager* pxm = this->getProxy()->GetProxyManager();
if (pxm)
{
......
......@@ -283,7 +283,7 @@ bool vtkPMProxy::CreateVTKObjects(vtkSMMessage* message)
this->VTKObject = this->Interpreter->GetObjectFromID(this->VTKObjectID);
}
#ifdef FIXME
#ifdef FIXME_COLLABORATION
// ensure that this is happening correctly in PMProxy
if (this->VTKClassName && this->VTKClassName[0] != '\0')
{
......
......@@ -153,7 +153,7 @@ struct vtkSMProxyManagerEntry
bool operator==(const vtkSMProxyManagerEntry &other) const {
return this->Group == other.Group && this->Name == other.Name
&& this->Proxy == other.Proxy;
&& this->Proxy->GetGlobalID() == other.Proxy->GetGlobalID();
}
bool operator<(const vtkSMProxyManagerEntry &other) const {
......@@ -161,6 +161,10 @@ struct vtkSMProxyManagerEntry
{
return true;
}
else if (this->Group == other.Group && this->Name == other.Name)
{
return this->Proxy->GetGlobalID() < other.Proxy->GetGlobalID();
}
else if (this->Group == other.Group)
{
return this->Name < other.Name;
......@@ -173,6 +177,10 @@ struct vtkSMProxyManagerEntry
{
return true;
}
else if (this->Group == other.Group && this->Name == other.Name)
{
return this->Proxy->GetGlobalID() > other.Proxy->GetGlobalID();
}
else if (this->Group == other.Group)
{
return this->Name > other.Name;
......@@ -293,7 +301,6 @@ struct vtkSMProxyManagerInternals
}
iter++;
}
}
void RemoveTuples( const char* name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment