[Paraview] loading Proxy from xml state

Nehme Bilal nbilal at mirarco.org
Sat Nov 22 02:56:40 EST 2008


Hello,

I am trying to copy proxy properties from xml state. the 
folowing code work well for "sources" proxies. It works 
also for "representations" proxies, but Instead of copying 
properties to the existing representation, it create 
another representation and I got this error:
"vtkSMStateLoader (0A075FD0): No root is defined. Cannot 
locate proxy element with id 74"
In Paraview I got two representations for the same source.
Here is my code:
void pqPowerView::loadProxyFromState(vtkPVXMLElement 
*stateElement,
																		 vtkSMProxy *smProxy )
{
	vtkSMProxyManager* pxm = vtkSMObject::GetProxyManager();
	vtkSMStateLoader *myLoader = vtkSMStateLoader::New();
	vtkPVXMLElement* collectionElement = 
vtkPVXMLElement::New();

	unsigned int numElems = 
stateElement->GetNumberOfNestedElements();
   unsigned int i=0;

   for (i=0; i<numElems; i++)
   {
     vtkPVXMLElement* currentElement = 
stateElement->GetNestedElement(i);
     if (currentElement->GetName() &&
       strcmp(currentElement->GetName(), "Proxy") == 0)
     {
			currentElement->AddNestedElement(collectionElement);
			if(QString(currentElement->GetAttribute("group")) == 
smProxy->GetXMLGroup()
				&& QString(currentElement->GetAttribute("id")) == 
QString(smProxy->GetSelfIDAsString()) )
			{
				vtkSMProxy *newProxy = 
pxm->NewProxy(smProxy->GetXMLGroup(), 
smProxy->GetXMLName());
				newProxy->LoadState(currentElement, myLoader);
				this->copyProxy(newProxy,smProxy);	

				if(!smProxy)
					qDebug() << "proxy not loaded";
			}
		}			
	}
}


void pqPowerView::copyProxy(vtkSMProxy* src, vtkSMProxy* 
dest)
{
	vtkSMPropertyIterator* iter = 
dest->NewPropertyIterator();
	for (iter->Begin(); !iter->IsAtEnd(); iter->Next())
		 {
		 vtkSMProperty* destProp = iter->GetProperty();
		 vtkSMProperty* srcProp = 
src->GetProperty(iter->GetKey());
		 if (destProp && srcProp)
			 {
			 destProp->Copy(srcProp);
			 }
		 }
	iter->Delete();
}

can you please tell me what am doing wrong ?

the goal is to restore the exposed properties for the xml 
state.

  


More information about the ParaView mailing list