Commit dbb819b6 authored by Sebastien Jourdain's avatar Sebastien Jourdain

Bring back pqProxyModifiedStateUndoElement

parent b4191454
......@@ -71,6 +71,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqPropertyManager.h"
#include "pqProxyModifiedStateUndoElement.h"
#include "pqSelectThroughPanel.h"
#include "pqServer.h"
#include "pqServerManagerModel.h"
#include "pqServerManagerObserver.h"
#include "pqSettings.h"
......@@ -523,13 +524,12 @@ void pqObjectInspectorWidget::accept()
if (source)
{
this->show(source);
#ifdef FIXME_COLLABORATION
pqProxyModifiedStateUndoElement* elem =
pqProxyModifiedStateUndoElement::New();
elem->SetSession(source->getServer()->session());
elem->MadeUnmodified(source);
ADD_UNDO_ELEM(elem);
elem->Delete();
#endif
}
}
......
......@@ -284,6 +284,8 @@ ADD_LIBRARY(pqCore
pqPropertyManager.h
pqProxy.cxx
pqProxy.h
pqProxyModifiedStateUndoElement.cxx
pqProxyModifiedStateUndoElement.h
pqQVTKWidget.cxx
pqQVTKWidgetEventPlayer.cxx
pqQVTKWidgetEventPlayer.h
......@@ -386,8 +388,6 @@ ADD_LIBRARY(pqCore
# pqHelperProxyRegisterUndoElement.cxx
# pqHelperProxyRegisterUndoElement.h
#
# pqProxyModifiedStateUndoElement.cxx
# pqProxyModifiedStateUndoElement.h
# pqProxyUnRegisterUndoElement.cxx
# pqProxyUnRegisterUndoElement.h
## pqScatterPlotRepresentation.cxx
......
......@@ -117,13 +117,12 @@ pqPipelineSource* pqObjectBuilder::createSource(const QString& sm_group,
source->setDefaultPropertyValues();
source->setModifiedState(pqProxy::UNINITIALIZED);
#ifdef FIXME_COLLABORATION
pqProxyModifiedStateUndoElement* elem =
pqProxyModifiedStateUndoElement::New();
elem->SetSession(server->session());
elem->MadeUninitialized(source);
ADD_UNDO_ELEM(elem);
elem->Delete();
#endif
emit this->sourceCreated(source);
emit this->proxyCreated(source);
return source;
......@@ -303,13 +302,12 @@ pqPipelineSource* pqObjectBuilder::createReader(const QString& sm_group,
reader->setDefaultPropertyValues();
reader->setModifiedState(pqProxy::UNINITIALIZED);
#ifdef FIXME_COLLABORATION
pqProxyModifiedStateUndoElement* elem =
pqProxyModifiedStateUndoElement::New();
elem->SetSession(server->session());
elem->MadeUninitialized(reader);
ADD_UNDO_ELEM(elem);
elem->Delete();
#endif
emit this->readerCreated(reader, files[0]);
emit this->readerCreated(reader, files);
......
......@@ -20,7 +20,7 @@
#include "vtkObjectFactory.h"
#include "vtkPVXMLElement.h"
#include "vtkSMProxy.h"
#include "vtkSMProxyLocator.h"
#include "vtkSMSession.h"
vtkStandardNewMacro(pqProxyModifiedStateUndoElement);
//----------------------------------------------------------------------------
......@@ -33,52 +33,26 @@ pqProxyModifiedStateUndoElement::~pqProxyModifiedStateUndoElement()
{
}
//----------------------------------------------------------------------------
bool pqProxyModifiedStateUndoElement::CanLoadState(vtkPVXMLElement* elem)
{
return (elem && elem->GetName() &&
strcmp(elem->GetName(), "ProxyModifiedState") == 0);
}
//----------------------------------------------------------------------------
void pqProxyModifiedStateUndoElement::MadeUnmodified(pqProxy* source)
{
vtkPVXMLElement* elem = vtkPVXMLElement::New();
elem->SetName("ProxyModifiedState");
elem->AddAttribute("id", source->getProxy()->GetSelfIDAsString());
elem->AddAttribute("reverse", 0);
this->SetXMLElement(elem);
elem->Delete();
this->ProxySourceGlobalId = source->getProxy()->GetGlobalID();
this->Reverse = false;
}
//----------------------------------------------------------------------------
void pqProxyModifiedStateUndoElement::MadeUninitialized(pqProxy* source)
{
vtkPVXMLElement* elem = vtkPVXMLElement::New();
elem->SetName("ProxyModifiedState");
elem->AddAttribute("id", source->getProxy()->GetSelfIDAsString());
elem->AddAttribute("reverse", 1);
this->SetXMLElement(elem);
elem->Delete();
this->ProxySourceGlobalId = source->getProxy()->GetGlobalID();
this->Reverse = true;
}
//----------------------------------------------------------------------------
bool pqProxyModifiedStateUndoElement::InternalUndoRedo(bool undo)
{
vtkPVXMLElement* element = this->XMLElement;
int id = 0;
element->GetScalarAttribute("id",&id);
if (!id)
{
vtkErrorMacro("Failed to locate proxy id.");
return false;
}
int reverse = 0;
element->GetScalarAttribute("reverse", &reverse);
vtkSMProxyLocator* locator = this->GetProxyLocator();
vtkSMProxy* proxy = locator->LocateProxy(id);
vtkSMProxy* proxy =
vtkSMProxy::SafeDownCast(
this->GetSession()->GetRemoteObject(this->ProxySourceGlobalId));
if (!proxy)
{
......@@ -89,12 +63,12 @@ bool pqProxyModifiedStateUndoElement::InternalUndoRedo(bool undo)
pqApplicationCore* core = pqApplicationCore::instance();
pqServerManagerModel* smModel = core->getServerManagerModel();
pqProxy* pqproxy = smModel->findItem<pqProxy*>(proxy);
if (pqproxy && !reverse)
if (pqproxy && !this->Reverse)
{
pqproxy->setModifiedState(undo? pqProxy::UNINITIALIZED :
pqProxy::UNMODIFIED);
}
else if (pqproxy && reverse)
else if (pqproxy && this->Reverse)
{
pqproxy->setModifiedState(undo? pqProxy::UNMODIFIED:
pqProxy::UNINITIALIZED);
......
......@@ -45,8 +45,6 @@ public:
return this->InternalUndoRedo(false)? 1 : 0;
}
virtual bool CanLoadState(vtkPVXMLElement*);
/// Use this to initialize the element if the pqProxy was marked as
/// UNMODIFIED.
void MadeUnmodified(pqProxy*);
......@@ -61,6 +59,8 @@ protected:
~pqProxyModifiedStateUndoElement();
bool InternalUndoRedo(bool undo);
vtkTypeUInt32 ProxySourceGlobalId;
bool Reverse;
private:
pqProxyModifiedStateUndoElement(const pqProxyModifiedStateUndoElement&); // Not implemented
void operator=(const pqProxyModifiedStateUndoElement&); // Not implemented
......
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